Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to check for valid currency value in javascript?

Status
Not open for further replies.

wvdba

IS-IT--Management
Jun 3, 2008
465
0
0
US
Hi.
i have a field in a page that i have to check for validity of currency. i know how to do it in vbscript/asp. but my edit routine is in javascript. the field is populated after user selects another option from a drop-down menu. the field shows up as $20.00
how would i check to see if it is a valid currency field with the $ sign beside it?
thanks.
 
?! this is the ASP forum, but you want a javascript answer?
you want a client side javascript check on a currecny field?
code snippet?
 
thanks.
my bad. since i was coding an asp page, i forgot that i need to put this in javascript forum.
:)
 
<script language=javascript>
var s="1s4";
alert(isCurrency(s));
function isCurrency(pInput) {
var re = /^\$?[0123456789\.-]+$/;
return re.test(pInput);
}
</script>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top