Revision: 48056
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at June 22, 2011 23:26 by dan_hoerr
Initial Code
<script> $(document).ready(function(){ $("#myform").validate({ groups: { username: "fname lname" }, errorPlacement: function(error, element) { if (element.attr("name") == "fname" || element.attr("name") == "lname" ) error.insertAfter("#lastname"); else error.insertAfter(element); }, rules: { fname:{ required:{ depends: function(element){ var status = false; if( $("#yesname:checked").val() !== undefined){ var status = true; } //console.log("yesname is: "+status); return status; } } }, lname:{ required:{ depends: function(element){ var status = false; if( $("#yesname:checked").val() !== undefined){ var status = true; } //console.log("yesname is: "+status); return status; } } } }, debug:true }) }); </script> <form id="myform"> <label for="name">Do you have a name?</label><br> <input type="checkbox" name="name" value="y" id="yesname">yes<br> <input type="checkbox" name="name" value="n" id="noname">no<br> <p>if you have a name give it to me!</p> <label>Your Name</label> <input name="fname" id="firstname" placeholder="first name..." /> <input name="lname" id="lastname" placeholder="last name..." /> <br/> <input type="submit" value="Submit"/> </form>
Initial URL
http://bassistance.de/jquery-plugins/jquery-plugin-validation/
Initial Description
Initial Title
Conditional JQuery Validate Required Field
Initial Tags
jquery
Initial Language
jQuery