Price number Regular Expression Verification:
Previously designed form data and found that the price control is not very reasonable
<Input name = "softprice" type = "text" id = "softprice" size = "10" maxlength = "5" value = "<% = SESSION (" softprice ") %> "onkeyup =" this. value = This. value. replace (// D/g, '')" onafterpaste = "this. value = This. value. replace (// D/g, '')"/>
All the modified code is executed in the data format detection program of the submitted form.
Function checkform1 ()
{
If (document. form1.softprice. value = "")
{
Alert ("Enter the software Price! ");
Document. form1.softprice. Focus ();
Return false;
}
If (ispricenumeric (document. form1.softprice. Value) = false)
{
Alert ("the software price data format does not meet the requirements! ");
Document. form1.softprice. Focus ();
Return false;
}
}
Function ispricenumeric (onum)
{
If (! Onum) return false;
// Var STRP =/^/d + (/./d + )? $ /;
VaR STRP =/^ [0-9] +/. [0-9] {0, 2} $ /;
If (! STRP. Test (onum) return false;
Try {
If (parsefloat (onum )! = Onum) return false;
}
Catch (Ex)
{
Return false;
}
Return true;
}