我有以下功能来验证手机号码。
function validate()
{
var a = document.form.mobile_no.value;
if(a=="")
{
alert("please Enter the Contact Number");
//document.form.mobile_no.focus();
return false;
}
if(isNaN(a))
{
alert("Enter the valid Mobile Number(Like : 9566137117)");
//document.form.mobile_no.focus();
return false;
}
if((a.length < 1) || (a.length > 10))
{
alert(" Your Mobile Number must be 1 to 10 Integers");
//document.form.mobile_no.select();
return false;
}
}
我已将表单中的函数称为:
<form action="" method="post" onsubmit="validate()" id="teacher_form">
来自用户的输入被视为:
但是这个过程并没有像它应该那样验证结果。无需输入验证即可接受该条目。