Friday, October 3, 2008

Amount validation using Regex and Java Script

I come through a way to validate amount field.
This script validates amount field.

- If the value have a dot, It must be preceded and followed by one or two numerals.

var val = /^-?\d+(\.\d+)?$/.test(document.frm.txt_amount.value);
if(!val)
{
alert("Please enter correct amount.");
return false;
}

No comments: