jQuery Validate 插件为表单提供了强大的验证功能,让客户端表单验证变得更简单,同时提供了大量的定制选项,满足应用程序各种需求。该插件捆绑了一套有用的验证方法,包括 URL 和电子邮件验证,同时提供了一个用来编写用户自定义方法的 API。所有的捆绑方法默认使用英语作为错误信息,且已翻译成其他 37 种语言。

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>Title</title><script type="text/javascript" src="js/jquery.js"></script><script type="text/javascript" src="js/jquery.validate.js"></script><script>$().ready(function(){var btn = document.getElementById("registerBtn");$("#registerBtn").mouseout(function () {btn.style.backgroundColor='orange';});$(btn).mouseover(function () {btn.style.backgroundColor='blue';});var $registForm = $("#registForm");var $submit = $(":submit");var $contact = $("#contact");var $password = $("#password");var $profile = $("#profile");$registForm.validate({rules: {password: {required: true,pattern: /^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(.{8,20})$/,minlength: 8,maxlength: 20},rePassword:{required: true,equalTo: "#password"},contact:{required: true,pattern:/^[\u4e00-\u9fa5a-z]+$/}},messages:{password: {required: "密码不能为空",pattern:  "密码必须是数字、字母的组合且字母必须包含大小写,且长度为8到20",minlength: "最小长度为8",maxlength: "最大长度为20"},rePassword:{required: "确认密码不能为空",equalTo: "确认密码必须与密码相同"},contact:{required: "姓名不能为空",pattern:  "姓名只能输入汉字或英文字母"}},submitHandler: function(form) {alert("验证通过,提交工单");$.ajax({url: $registForm.attr("action"),type: "POST",data: {contact: $contact.val(),password: $password.val(),profile:  $profile.val()},dataType: "json",cache: false,success: function(message) {if (message.type == "success") {$.message("登录成功!");$submit.prop("disabled", false);} else {$.message(message);$submit.prop("disabled", false);}}});}});});</script>
</head>
<body>
<form id="registForm" action="#" method="post"><table><tr><th>姓名:</th><td><input type="text" name="contact" id="contact"/></td></tr><tr><th>密码:</th><td><input type="password" name="password" id="password"/></td></tr><tr><th> 确认密码:</th><td><input type="password" name="rePassword" id="rePassword"/></td></tr><tr><th> 个人简介:</th><td><textarea style="height: 60px;" id="profile" name="profile"></textarea></td></tr><tr><td colspan="2"><button  style="width:100%;margin-top:20px;background-color: orange" type="submit" id="registerBtn">注册</button><button type="button" onclick="resetForm();" id="resetBtn">重置</button></td></tr></table>
</form>
<script>function resetForm() {$("#registForm")[0].reset();}
</script>
</body>
</html>

jQuery Validate 初见面相关推荐

  1. jquery validate初上手

    前言:jquery validate初上手,这个标题不知道是否合适,因为之前已经在dwz中用过validate.但是,毕竟是经过zhanghuihua同学封装过的,对于bootstrap的表单验证,还 ...

  2. jquery validate使用

    一.用前必备  官方网站:http://bassistance.de/jquery-plugins/jquery-plugin-validation/  API: http://jquery.bass ...

  3. jquery validate 详解一

    jQuery校验 官网地址:http://bassistance.de/jquery-plugins/jquery-plugin-validation 一导入js库 <script src=&q ...

  4. jQuery校验 jQuery Validate 表单验证详解

    官网地址: http://bassistance.de/jquery-plugins/jquery-plugin-validation 一导入js库 <script src="../j ...

  5. jQuery Validate

    2019独角兽企业重金招聘Python工程师标准>>> 贴上链接 http://www.runoob.com/jquery/jquery-plugin-validate.html & ...

  6. jquery.validate不用submit而用js提交的例子

    $("#form").validate(); $("#btn).click(function(){if($("#form").valid()){$(& ...

  7. jQuery验证控件jquery.validate.js使用说明+中文API

    官网地址:http://bassistance.de/jquery-plugins/jquery-plugin-validation jQuery plugin: Validation 使用说明 转载 ...

  8. [jQuery]使用jQuery.Validate进行客户端验证(高级篇-下)——不使用微软验证控件的理由...

    2019独角兽企业重金招聘Python工程师标准>>> 引用源:http://www.cnblogs.com/kyo-yo/archive/2010/07/06/Use-jQuery ...

  9. jQuery Validate 表单验证插件----自定义校验结果样式

    一.下载依赖包 网盘下载:https://yunpan.cn/cryvgGGAQ3DSW  访问密码 f224 二.引入依赖包 <script src="../../scripts/j ...

最新文章

  1. Visual Studio 2008 使用小技巧
  2. mysql在mac下的data目录_Mysql在mac中目录结构用法命令
  3. 16、Java Swing JProgressBar:进度条组件
  4. Qt学习笔记之QTranslator
  5. notepad++修改背景色
  6. WEB前端 vue学习二 组件之间的数据传递
  7. stm8因为固定中断向量表地址引发的一系列问题及其处理
  8. MongoDB在Linux下常用优化设置
  9. UVA 213 Message Decoding
  10. 使用keras为什么accuracy一直为0_TensorFlow 2.0+Keras 防坑指南
  11. DevExpress gridcontrol添加了复选框删除选中的多行/批量删除的方法
  12. c++枚举和c语言枚举_C语言枚举初学者指南
  13. php我的世界网页地图,探险家地图 - Minecraft Wiki,最详细的官方我的世界百科
  14. 机器学习笔记最大熵之NER
  15. Ubuntu虚拟机下载(清华大学开源软件镜像源)
  16. 怎么用计算机弹出soldout,《SOLDOUT2》游戏怎么玩 游戏攻略玩法全面介绍
  17. 关于兼容导入excel2003和excel2007版本注意事项
  18. layui中表格嵌套表格
  19. Python教程之粒子运动轨迹动态绘图
  20. 某宝上关于PMP低价续证,可信吗?

热门文章

  1. 【3】docker-compose
  2. XShell安装lrzsz实现文件上传到Linux服务器
  3. MongoDB中的索引操作
  4. 基于jedis的Redis工具类
  5. springboot整合ehcache+redis实现双缓存
  6. 怎样查看JVM的默认收集器
  7. 企业运维几百个重点面试题汇总(老男孩)
  8. oralce 11g rac ocr和votedisk迁移
  9. Java程序员从笨鸟到菜鸟之(五十一)细谈Hibernate(二)开发第一个hibernate基本详解...
  10. 基于最简单的FFmpeg包封过程:视频和音频分配器启动(demuxer-simple)