I am trying to validate dependent inputs field , but i am n't getting any idea..
Suppose i have 3 fields named first_name, middle_name and age . If all the fields are empty or blank then it is ok, but when first field is filled then other two must required & validate properly... so how could i achieve this using jquery. i am using jquery.js and jquery.validate.js
<script>
$(document).ready(function(){
$("#frm").validate({
rules:{
middle_name:{
required: function(element) {
return $('input[name="first_name"]').val() != '';
}
}
},
messages:{
middle_name:{
required:"now it is mandatory.."
},
});
});
</script>