Phone validation control
Hey friends I want to control textbox value is just number... I dont want alphabeth caracters or spacial caracters.. like @ -开发者_StackOverflow社区 / ^ ' a b c
I actually control textbox value is a phone number..
help me!
u can use the following code in jsp to validate numbers only
function isNumber(elem) {
var str = elem.value;
var re = /^[-]?\d*\.?\d*$/;
str = str.toString();
if (!str.match(re)) {
alert("Enter only numbers into the field.");
setTimeout("focusElement('" + elem.form.name + "', '" + elem.name + "')", 0);
return false;
}
return true;
}
精彩评论