这篇文章主要介绍了jquery实现验证表单密码一致性及正则表达式验证邮箱、手机号的方法,涉及jquery表单元素获取及正则验证相关操作技巧,需要的朋友可以参考下
本文实例讲述了jQuery实现验证表单密码一致性及正则表达式验证邮箱、手机号的方法。
jQuery 脚本
<script>
function check_password() {
if ($("#password").val() != $("#checkPWD").val()){
alert("请保证两次输入密码的一致性!");
$("#checkPWD").focus();
}
}
function check_email() {
var reg = /\w+[@]{1}\w+[.]\w+/;
if (!reg.test($("#email").val())){
alert("请输入正确的email!");
$("#email").focus();
}
}
function check_phone() {
var reg = /^1[34578]\d{9}$/;
if (!reg.test($("#phone").val())){
alert("请输入正确的手机号!");
$("#phone").focus();
}
}
</script>
html 文件
html> <script></script> <meta> <title>注册界面</title> <center> <h1>用户注册</h1> <form> <table> <tr> <td>用户名</td> <td><input></td> </tr> <tr> <td>密 码</td> <td><input></td> </tr> <tr> <td>确认密码</td> <td><input></td> </tr> <tr> <td>手机号码</td> <td><input></td> </tr> <tr> <td>邮箱</td> <td><input></td> </tr> <tr> <td> <input> <input> </td> </tr> </table> </form> </center>
运行结果:


上面是我整理给大家的,希望今后会对大家有帮助。
手机号卡联盟系统源码是一套面向手机卡、号卡推广分销业务的联盟型平台程序,底层对接号卡极团供货体系,可将运营商号卡产品直接接入自有平台进行展示与推广,适合做号卡代理、推广分润与多商户联盟运营的场景。系统支持源码部署,采用开源形式并附带正版授权,可在线更新。
相关文章:










