到目前为止,但不会工作?年龄验证Javascript
//if no age was entered it will allow
var age=document.getElementById('age1').value;
if(age == "")
return true;
//check if age is a number or less than or greater than 100
if (isNaN(age)||age<1||age>100)
{
alert("The age must be a number between 1 and 100");
return false;
}
我只是需要验证!!!!
很好的建议,但你想给一个更具体的正则表达式模式。尝试对'donotmatch100','donotmatch10or0'和'donotmatch10or0orme'的正则表达式。 –
Thiks @Tanzeel Kazi,我已更新回答 –
不客气。 :) –