Quack
asked on
I have a form field that needs to allow commas for the input but also be in the N.NN Format...see code below...
Here's the code I'm using:
Won't catch where I need it to. Anyone see where this would be failing?
jQuery.validator.addMethod(
"money",
function(value, element) {
var isValidMoney = /^(\d+|\d{1,3}(,\d{3})*)(\.\d{2})?$/.test(value);
if(isValidMoney) {
var testValue = value;
testValue = testValue.replace(",","",-1);
if(testValue <= 0){
isValidMoney = false;
}
}
return this.optional(element) || isValidMoney;
},
"Insert"
);
}
, Invoice_Amount: {
required: true
, money: true
, pattern: /^\d+\.\d{0,2}$/
, min: .01
}
Won't catch where I need it to. Anyone see where this would be failing?
can you create a jsfiddle for it, easier to debug and make a change
ASKER
not sure what a jsfiddle is :-(
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks