Skip to content

Instantly share code, notes, and snippets.

@ataylorme
Last active December 11, 2015 17:58
Show Gist options
  • Save ataylorme/4637868 to your computer and use it in GitHub Desktop.
Save ataylorme/4637868 to your computer and use it in GitHub Desktop.
disallows 0, negative numbers, blank value. Commas two decimal places are optional
$.validator.addMethod("UScurrency", function (value) {
return value.match(/^\$?[^-]?[1-9]([0-9]+,?)*(\.([0-9]{1,2}))?$/) || value == "" || Number(value) > 0;
}, "Please enter a valid dollar amount");
form.validate({
});
$.validator.addClassRules({
currency: {
UScurrency: true
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment