View Full Version : Regular Expression

07-25-2010, 12:38 AM
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?

07-25-2010, 12:42 AM
Ah, got it guys... my Reg Ex should be


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

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


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