need help with validation, toggle, checkbox etc...

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

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

ok thx