<!--H5表单验证:-->
<!--1、-->
<form>

<input class="phone" type="text" placeholder="请输入手机号码" required="required" pattern="^[1][0-9]{10}$" oninvalid="setCustomValidity('手机号格式不正确')"/>
/>
    <input type='submit'/>
   </form>

<!--2、-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>正则</title>
</head>
<body>
<form action="#">
<input class="phone" type="text" placeholder="请输入电话号码!"/>
<input class="phone" type="text" placeholder="请输入手机号码" required="required" pattern="^[1][0-9]{10}$" oninvalid="setCustomValidity('手机号格式不正确')"/>
<input type="submit"/>
</form>
<script type="text/javascript" src="./bootstrap/js/jquery-1.11.3.js"></script>
<script type="text/javascript" src="./bootstrap/js/bootstrap.js"></script>
<script>
$(
".phone").blur(function(){ var reg = /^[1][34578][0-9]{9}$/; var val = $(this).val(); if(!reg.test(val)){ alert("手机号格式错误!"); }; });
</script>
</body>
</html>
<!--3、-->
<html> 
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>江哥讨厌IE</title>
</head>
<body>
<input type="text" id="btn_getNum"/>
<input type="button" value="得到数字" onclick="checkMobile(btn_getNum.value);"/>
<script language="javascript" type="text/javascript"> function checkMobile(str) { if(str==""){ alert("手机号不能为空!"); } else{ var re = /^1\d{10}$/ if (re.test(str)) { alert("正确"); } else { alert("手机号格式错误!"); } } }
</script>
</body>
</html>
<!--4、jQuery实时计算用户输入字数
-->
>

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-31
  • 2022-12-23
  • 2021-10-29
  • 2021-07-21
猜你喜欢
  • 2021-11-11
  • 2022-12-23
  • 2021-11-28
  • 2022-12-23
  • 2021-11-04
  • 2021-06-22
  • 2022-03-08
相关资源
相似解决方案