HTML
-----------
$.validator.addMethod("taxAmount_validate", function(value, element, param) { var taxtype = $('#taxType').val(); if (taxtype >= 0) { if (taxtype == 0) { if (value <= 0) { return false; } else { return true; } } if (taxtype == 1 || taxtype == 2) { if (value != 0) { return false; } else { return true; } } } }); $("#taxForm").validate({ debug: true, //prevent submission for testing rules: { taxAmount: { taxAmount_validate: true } }, messages: { taxAmount: { taxAmount_validate: "Enter validate tax amount!." }, } });
Form Validation Example
--------------- Jquery ------------------$.validator.addMethod("taxAmount_validate", function(value, element, param) { var taxtype = $('#taxType').val(); if (taxtype >= 0) { if (taxtype == 0) { if (value <= 0) { return false; } else { return true; } } if (taxtype == 1 || taxtype == 2) { if (value != 0) { return false; } else { return true; } } } }); $("#taxForm").validate({ debug: true, //prevent submission for testing rules: { taxAmount: { taxAmount_validate: true } }, messages: { taxAmount: { taxAmount_validate: "Enter validate tax amount!." }, } });
No comments:
Post a Comment