Reputation: 1
Actually I am a new user of LAMP(Linux, Apache, Mysql, PHP). I have created a web page using php scripts and have used sort of validation rules by js validation plugin to validate form inputs (textbox, email etc).
I have created 2 dropdown list .
(a) "Category" contains options as Child,Adult
(b) "Seat" contains options as NON-AC,AC
Then I have used a text box: "Amount" which receives input as integer. The conditions are
child & Non-AC - 150 (as Amount)
Child & AC -200 (as Amount)
I have to validate Amount textbox by considering the inputs form both the dropdown list.
I have searched for jquery validation.js and found the min constraint. but didn't get way to custom validation code to validate textbox using min and input from the dropdown list.
I will be very thankful , if someone helps me out.
Upvotes: 0
Views: 1807
Reputation: 5803
Try to do this:---
jQuery('#Category).change(function() {
//ur code comes here..
//here you can give ur condition based on category changed..
});
Upvotes: 0
Reputation: 1838
You can write your own validation method like follow
jQuery.validator.addMethod(
"amountcheck",
function(value,element){
// value ==> the value of text box , element ==> the text box
var category = $("#category").val();
var seat = $("#seat").val();
// check it's valid or not..
if (true){
return this.optional(element) || true;
}else{
return this.optional(element) || false;
}
},
"Invalid Amount"
);
Then
$(form).validation({
rules:{
Amount:{
amountcheck:true
}
}
})
Upvotes: 1