0

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

2 Answers 2

1

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
}
Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.