Monday, August 13, 2012

Taxable Field Validation

HTML -----------

Form Validation Example

Tax Type:

Sale tax amount:

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