Hi cplusplus1 Please try the following code, it only allow positive or negative numbers, and at most two two decimals: <html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript">
function validate()
{
var pattern = /^-?[0-9]+(.[0-9]{1,2})?$/;
var text = document.getElementById('textbox1').value;
if (text.match(pattern)==null)
{
alert('the format is wrong');
}
else
{
alert('OK');
}
}
</script>
</head>
<body style="font-family:Calibri">
<input type='text' id='textbox1' />
<input type='button' value='OK' onclick="validate();">
</body>
</html>
If I’ve misunderstood the facing problem, please feel free to let me know.
Thanks.