Reputation: 63
I am using the jquery.validate and the jquery.formatCurrency plugin.
I'd like to use an "addmethod" to add a range of "currency" to validate but am not sure how to work this to play nice with the formatCurrency plugin..
Essentially, I have a project where I want to do something like "rangeCurr: [1000, 100000]" and have it accept answers such as $1,000 or $1,000.00 or whatever gets reformatted byu the currency plugin.
if anyone has a clue, link or some ideas, that'd be great.
Thanks, Dan
Upvotes: 2
Views: 562
Reputation: 78590
In your submitHandler(?) function or wherever need be (never actually used this plugin), you could change the value that is passed to the plugin method to strip out the formatting. You could use a regex like the following:
var value = "$1,230,000.45";
var newval = Number(value.match(/[0-9.]/g).join(""));
Upvotes: 1