RegEx/Javascript validation: Don't allow comma as a valid character
Posted
by baldwingrand
on Stack Overflow
See other posts from Stack Overflow
or by baldwingrand
Published on 2010-05-18T20:21:10Z
Indexed on
2010/05/18
20:30 UTC
Read the original article
Hit count: 276
regex
|JavaScript
I'm doing Javascript validation on my number fields. I'm using RegEx to do this - first time RegEx user. I need the user to only enter numbers and decimals, but not commas. (i.e. 3600.00 is okay, but 3,600.00 is not). I can't figure out how to eliminate the commas as an accepted character. Any help is appreciated. Thanks!
var filter = /^([0-9])/;
if (!filter.test(txtItemAmount.value))
{
msg += "Item amount must be a number.\n";
txtItemAmount.focus
}
© Stack Overflow or respective owner