Dungu Chu
Dungu Chu

Reputation: 1

Dropdown validation in JQuery

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 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

Answers (2)

FrontEnd Expert
FrontEnd Expert

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

Willy
Willy

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

Related Questions