到目前爲止,但不會工作?年齡驗證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,我已更新回答 –
不客氣。 :) –