hi,
i have the following code in js:
basically, it tests for currency. it works the way in the code above. however, i want to take the two functions and put them in a js file with include. i have tried several snippets from web to include these, but the functions do not work when i use include. if i put the code as above, it works.
any idea why this is?
thanks.
i have the following code in js:
Code:
<script language="javascript">
function isUSCurrency (sString) {
return RegExp(/^\$?\d+(\.\d{2})?$/).test(String(sString).replace(/^\s+|\s+$/g, ""));
}
</script>
<script language="javascript">
function myfunc()
{
var amt = document.forms['frm1'].elements['amt'].value;
if(!isUSCurrency(amt))
{
alert("bad amount.");
}
if(isUSCurrency(amt))
{
alert("amouht is good.")
}
}
</script>
<form name="frm1" action="test_currency.html" method="post" onSubmit="return myfunc();"
<INPUT type="text" NAME="amt" id="amt" size=8>
<br><br>
<input type="hidden" name="submit" value="submit">
<INPUT TYPE="submit" class="GO" value="submit">
<INPUT TYPE="reset" class="GO" VALUE="Clear">
</form>
any idea why this is?
thanks.