...

View Full Version : Regular Expression



JonathanStanton
07-24-2010, 11:38 PM
I want to validate a form with only numbers and "$" sign.
so far i know this

currencyValue = which.value;
var re = /^[0-9]*$/;
if (!re.test(currencyValue)) {
alert("Value must be all numberic charcters, non numeric's removed from field!");
field.value = field.value.replace(/D/g,"");
}


but how do I also add the "$" sign as ok?

JonathanStanton
07-24-2010, 11:42 PM
Ah, got it guys... my Reg Ex should be

/^[0-9\,\.\$]*$/

Philip M
07-25-2010, 09:07 AM
field.value = field.value.replace(/D/g,"");

That will replace the capital letter D with "" (nothing).

Try

field.value = field.value.replace([^0-9\,\.\$]/gi, "");


All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum