标签:text turn check maxlength input blog 手机号码 否则 .com
http://uule.iteye.com/blog/2183622
<form class="form" method="post" id="form" onsubmit="return checkForm(this)" action="">
电话号码:<input id="tel" type="text" maxlength="11" name="tel"/>
<button type="submit" name="submit" value="提交"/>
</form>
function checkForm(o){
var re=/^(13[0-9]{9})|(15[89][0-9]{8})$/;
if(!re.test(o.tel.value)){
alert('请输入正确的手机号码。');
return false;
}
}
function submitFun(){
//逻辑判断
return true; //允许表单提交
//逻辑判断
return false;//不允许表单提交
}
<form onsubmit="reture submitFun();"></form>
//注意此处不能写成 onsubmit="submitFun();"否则将表单总是提交
标签:text turn check maxlength input blog 手机号码 否则 .com
原文地址:https://www.cnblogs.com/iiiiiher/p/9790191.html