check for positive numbers using regular expression.

Rajni.Shekhar
Posted by Rajni.Shekhar under JavaScript category on | Points: 40 | Views : 4333
function CheckNumericValue(id) {
var num = /^[0-9\s\+]+$/;
var txt=document.getElementById(id).value;
if (txt != "") {
if (!txt.match(num)) {
alert("Please enter positive numbers only");
document.getElementById(id).focus()
return false;
}
}
else {
alert("Please enter some value in textbox.");
document.getElementById(id).focus()
return false;
}
}

Comments or Responses

Login to post response