Wednesday 15 April 2015

javascript - Add dynamic validation text to custom jQuery validation rule -


I have written a jQuery validation rule which displays the failure certification if the amount entered in input is 5000 or less 500000 more than. I am trying to set a verification message to a variable to be dynamic in the rule, but I am having a problem saying that I have not defined my approval message.

  # Error unwanted references: The error is not valid # Custom rules $ Validator.addMethod ("requestAmount", function (value, element) {var cleanAmount = value.replace (/ \, / g, ''); var validation message = ''; console.log (clean expression) (clean AMT ;5000) {var validation message = 'Enter more than $ 5,000.00 amount; return return;} and if (clean deposit> 500000) {var validationMessage =' Please enter less than amount amount $ 500,000.00 '; return false;} Other {return true;};}, verification message);    

Announce and remove var validationMessage outside the function scope var each time you set the value to verification message :

  var validationMessage; # Custom rules $ Validator.addMethod ("requestAmount", function (value, element) {var cleanAmount = value.replace (/ \, / g, ''); validation message = ''; console.log (cleanAmount) if (clean amount & amp; ;5000) {Validation message = Enter amount greater than $ 5,000.00; Return return;} And if (clean amount> 500000) {Validation message = 'Enter less than $ 500,000.00'; Return return;} and return True;};}}, function () {return verification message;});  

No comments:

Post a Comment