validate() > show field after radiobutton selection

Posted by RihanU on Stack Overflow See other posts from Stack Overflow or by RihanU
Published on 2010-05-20T22:07:06Z Indexed on 2010/05/20 22:10 UTC
Read the original article Hit count: 315

Filed under:
|

hi im saw this jquery script: http://jquery.bassistance.de/validate/demo/ and i want also the posibility to show a field when a button is checked but not with a checkbox. but with two radiobuttons. if radiobutton1 is checked, display field1 and if radiobutton2 is checked display field 2 what do i have to change..?

 <script type="text/javascript">
$().ready(function() {
 //code to hide topic selection, disable for demo
 var foo = $("#foo");
 // foo topics are optional, hide first
 var inital = foo.is(":checked");
 var topics = $("#blaat")[inital ? "removeClass" : "addClass"]("gray");
 var topicInputs = topics.find("input").attr("disabled", !inital);
 // show when foo is checked
 foo.click(function() {
  topics[this.checked ? "removeClass" : "addClass"]("gray");
  topicInputs.attr("disabled", !this.checked);
 });
});
</script>
<form class="cmxform" id="signupForm" method="get" action="">
 <fieldset>
  <p>
   <label for="foo">De checkbox dus veranderen naar 2 radio buttons</label>
   <input type="checkbox" class="checkbox" id="foo" name="foo" />
            <!--  
            <input type="radio" value="ding" class="checkbox" id="foo" name="foo" />
            <input type="radio" value="dong" class="checkbox" id="foo" name="foo" />
            -->
  </p>
        <!-- Fieldset 1 -->
  <fieldset id="blaat">
   <label for="topic_marketflash">
    <input type="checkbox" id="topic_marketflash" value="marketflash" name="topic" />
    Marketflash
   </label>
   <label for="topic_fuzz">
    <input type="checkbox" id="topic_fuzz" value="fuzz" name="topic" />
    Latest fuzz
   </label>
   <label for="topic_digester">
    <input type="checkbox" id="topic_digester" value="digester" name="topic" />
    Mailing list digester
   </label>
  </fieldset>
  <!-- -->
        <!-- Fieldset 2 -->
  <fieldset id="andere">
   <label for="topic_marketflash">
    <input type="checkbox" id="topic_marketflash" value="marketflash" name="topic" />
    Voor
   </label>
   <label for="topic_fuzz">
    <input type="checkbox" id="topic_fuzz" value="fuzz" name="topic" />
    Beelden
   </label>
  </fieldset>
        <!-- -->        
 </fieldset>
</form>

© Stack Overflow or respective owner

Related posts about validate

Related posts about jQuery