网页特效栏目收集了最全最新的前端网页插件,包括最流行的jQuery,Bootstrap,Js,Css,Vue等主流特效插件。
这是一款非常简单实用的jquery 注册表单代码,对用户名,注册邮箱,密码,昵称的输入进行了实时验证。对验证代码做了很好的封装,调用起来非常简单。
1.引入js,css样式文件
<link rel="stylesheet" href="css/style.css">
<script type="text/javascript" src="js/jquery-2.1.0.min.js"></script>
<script type="text/javascript" src="js/easyform.js"></script>
2.添加表单和验证代码
<div class="form-div">
<form id="reg-form" action="" method="post">
<table>
<tr>
<td>用户名</td>
<td><input name="uid" type="text" id="uid" easyform="length:4-16;char-normal;real-time;" message="用户名必须为4—16位的英文字母或数字" easytip="disappear:lost-focus;theme:blue;" ajax-message="用户名已存在!">
</td>
</tr>
<tr>
<td>密码</td>
<td><input name="psw1" type="password" id="psw1" easyform="length:6-16;" message="密码必须为6—16位" easytip="disappear:lost-focus;theme:blue;"></td>
</tr>
<tr>
<td>确认密码</td>
<td><input name="psw2" type="password" id="psw2" easyform="length:6-16;equal:#psw1;" message="两次密码输入要一致" easytip="disappear:lost-focus;theme:blue;"></td>
</tr>
<tr>
<td>email</td>
<td><input name="email" type="text" id="email" easyform="email;real-time;" message="Email格式要正确" easytip="disappear:lost-focus;theme:blue;" ajax-message="这个Email地址已经被注册过,请换一个吧!"></td>
</tr>
<tr>
<td>昵称</td>
<td><input name="nickname" type="text" id="nickname" easyform="length:2-16" message="昵称必须为2—16位" easytip="disappear:lost-focus;theme:blue;"></td>
</tr>
</table>
<div class="buttons">
<input value="注 册" type="submit" style="margin-right:20px; margin-top:20px;">
<input value="我有账号,我要登录" type="button" style="margin-right:45px; margin-top:20px;">
</div>
<br class="clear">
</form>
</div>
<script type="text/javascript">
$(document).ready(function(){
$('#reg-form').easyform();
});
</script>
以上就是jquery 注册表单验证的使用方法,是不是非常简单。更多实用的网站代码请关注帝国模板之家。
转载请注明来源:简单实用的jquery 注册表单验证代码实例
本文永久链接地址:https://www.moyouyouw.cn/code/511.html
郑重声明:本站所有主题/文章除标明原创外,均来自网络转载,版权归原作者所有,如果有侵犯到您的权益,请联系本站删除,谢谢!我们不承担任何技术及版权问题,且不对任何资源负法律责任。
上一篇
下一篇
已有 位小伙伴发表了看法
欢迎 你 发表评论