I've created a script that will test if the user enters numeric data (or any data at all for that matter). It works fine except for one thing - if the user enters "2d", it still reads it as true and doesn't recognise the alpha character. Can someone look at my code and tell me what I'm doing wrong? I'm just trying to beat my users to the punch (before they start doing things they're not supposed to). Thanks. My code is below:
<SCRIPT type="text/JavaScript">
function Validate()
{
var Tax;
var Freight;
Tax = parseFloat(frmPOInfo.strTax.value);
Freight = parseFloat(frmPOInfo.strFreightAmt.value);
if (isNaN(Tax) && frmPOInfo.strTax.value.length != 0)
{
alert("You must enter numeric data for Tax amount."
;
return false
}
else if (isNaN(Freight) && frmPOInfo.strFreight.value.length != 0)
{
alert("You must enter numeric data for Freight amount."
;
return false
}
}
</SCRIPT>
<SCRIPT type="text/JavaScript">
function Validate()
{
var Tax;
var Freight;
Tax = parseFloat(frmPOInfo.strTax.value);
Freight = parseFloat(frmPOInfo.strFreightAmt.value);
if (isNaN(Tax) && frmPOInfo.strTax.value.length != 0)
{
alert("You must enter numeric data for Tax amount."
return false
}
else if (isNaN(Freight) && frmPOInfo.strFreight.value.length != 0)
{
alert("You must enter numeric data for Freight amount."
return false
}
}
</SCRIPT>