# Need help with validation, toggle, checkbox etc

**URL:** <https://www.ruby-forum.com/t/need-help-with-validation-toggle-checkbox-etc/190934>\
**Category:** Rails\
**Created:** [July 1, 2010, 2:12am UTC](https://www.ruby-forum.com/t/need-help-with-validation-toggle-checkbox-etc/190934 "2010-07-01T02:12:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomtt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e47c2d/32.png) [@tomtt](https://www.ruby-forum.com/u/tomtt)\
**Post date:** [July 1, 2010, 2:12am UTC](https://www.ruby-forum.com/t/need-help-with-validation-toggle-checkbox-etc/190934/1 "2010-07-01T02:12:24Z")

</div>

hi,  
im gettin lost with the subject. need some pointers:

Usermodel:  
validates\_presence\_of :companyname, :if =\> :is\_company?

\<%= f.label "Are u representing a company?" %\> \<%= f.check\_box :is\_company, :onclick =\> "new Effect.toggle('div\_company'); //if($('user\_is\_company').value == 0){$('user\_is\_company').value =1;} //if($('user\_is\_company').value == 1){$('user\_is\_company').value =0;} //alert(escape($('user\_is\_company').value))" %\>

 Details 

\<%= f.label "Company Name" %\>  
\<%= f.text\_field :companytitle %\>

......

my problem is:  
if someone is signing up AND checking the box “is\_company” the company  
detail div appears. now, if the company details dont pass the  
validation,  
the page gets naturally reloaded and the checkbox is\_company stays  
checked  
but the div is hidden.

tried several ways , but all end up in chaos…

does anyone have any working snippets?/thx

---

<div class="post-metadata">

**Author:** ![tomtt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e47c2d/32.png) [@tomtt](https://www.ruby-forum.com/u/tomtt)\
**Post date:** [July 1, 2010, 3:52pm UTC](https://www.ruby-forum.com/t/need-help-with-validation-toggle-checkbox-etc/190934/2 "2010-07-01T15:52:28Z")

</div>

ok thx

---

<div class="post-metadata">

**Author:** ![tomtt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e47c2d/32.png) [@tomtt](https://www.ruby-forum.com/u/tomtt)\
**Post date:** [July 1, 2010, 3:00am UTC](https://www.ruby-forum.com/t/need-help-with-validation-toggle-checkbox-etc/190934/3 "2010-07-01T03:00:23Z")

</div>

You need to add condition, where if a box is checked show div.
