tags:

views:

35

answers:

2

Hi,
I've been developing a publications application that has a drop down menu where you choose one of the publications types the form then changes(using jquery) to show and hide fields that are required. For example:

Every Publication:   
Title 

Conference:  
Start Date  
End Date

Journal:  
Volume  
Number

What i am wondering is how i could get form validation to work so that it doesn't say one of the journal paper fields are required when the user is inputting a conference paper.
Thanks in Advance,
Dean

A: 

Validation plugin works on classes?

input type="text" class="validate" ...

If you do a check: if paper = conference paper then remove class from "not more required" fields

Nealv
+1  A: 

You can use the value of the dropdown to determine which validation rules to run:

var type = $('#your-select').val();
if(type == "conference"){
    // conference validation rules
} else if (type == "journal"){
    // journal validation rules
} 

Or check if a field is hidden. If no, run validation on it:

if(!$('#your-field').is(':hidden')){
    // run validation
}
Pat