JQuery之validate入门
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title>网站注册页面</title>
- <style>
- #contanier{
- border: 0px solid white;
- width: 1300px;
- margin: auto;
- }
- #top{
- border: 0px solid white;
- width: 100%;
- height: 50px;
- }
- #menu{
- border: 0px solid white;
- height: 40px;
- background-color: black;
- padding-top: 10px;
- margin-bottom: 15px;
- margin-top: 10px;
- }
- .top{
- border: 0px solid white;
- width: 405px;
- height: 100%;
- float: left;
- padding-left: 25px;
- }
- #top1{
- padding-top: 15px;
- }
- #bottom{
- margin-top: 13px;
- text-align: center;
- }
- #form{
- height: 500px;
- padding-top: 70px;
- background-image: url(../img/regist_bg.jpg);
- margin-bottom: 10px;
- }
- a{
- text-decoration: none;
- }
- label.error{
- background:url(../img/unchecked.gif) no-repeat 10px 3px;
- padding-left: 30px;
- font-family:georgia;
- font-size: 15px;
- font-style: normal;
- color: red;
- }
- label.success{
- background:url(../img/checked.gif) no-repeat 10px 3px;
- padding-left: 30px;
- }
- #father{
- border: 0px solid white;
- padding-left: 307px;
- }
- #form2{
- border: 5px solid gray;
- width: 660px;
- height: 450px;
- }
- </style>
- <script type="text/javascript" src="../js/jquery-1.11.0.min.js" charset="UTF-8"></script>
- <script type="text/javascript" src="../js/jquery.validate.min.js" charset="UTF-8"></script>
- <script type="text/javascript" src="../js/messages_zh.js" charset="UTF-8"></script>
- <script>
- $(function() {
- $("#registForm").validate({
- rules:{
- user:{
- required:true,
- minlength:3
- },
- password:{
- required:true,
- digits: true,
- minlength:6
- },
- repassword:{
- required:true,
- equalTo: "[name='password']"
- },
- email:{
- required:true,
- email: true
- },
- username:{
- required:true,
- minlength:3,
- maxlength:5
- },
- sex: {
- required: true
- }
- },
- messages:{
- user:{
- required:"用户名不能为空!",
- minlength:"用户名不得少于3位!"
- },
- password:{
- required:"密码不能为空!",
- digits: "密码必须是数字",
- minlength:"密码不能少于6位"
- },
- repassword:{
- required:"确认密码不能为空!",
- equalTo: "两次输入密码不一致!"
- },
- email:{
- required:"邮箱不能为空",
- email: "邮箱格式不支持"
- },
- username:{
- required:"姓名不能为空!",
- minlength:"姓名不得少于3位!",
- maxlength:"姓名不超过5位!"
- },
- sex: {
- required: "性别必须勾选!"
- }
- },
- errorElement: "label", //用来创建错误提示信息标签
- success: function(label) { //验证成功后的执行的回调函数
- //label指向上面那个错误提示信息
- label.text(" ") //清空错误提示信息
- .addClass("success"); //加上自定义success类
- }
- });
- });
- </script>
- </head>
- <body>
- <div id="contanier">
- <div id="top">
- <div class="top">
- <img src="../img/logo2.png" height="47px"/>
- </div>
- <div class="top">
- <img src="../img/header.png" height="45px" />
- </div>
- <div class="top" id="top1">
- <a href="#">登录</a>
- <a href="#">注册</a>
- <a href="#">购物车</a>
- </div>
- </div>
- <div id="menu">
- <a href="#"><font size="5" color="white">首页</font></a>
- <a href="#"><font color="white">电脑办公</font></a>
- <a href="#"><font color="white">手机数码</font></a>
- <a href="#"><font color="white">鞋靴箱包</font></a>
- </div>
- <div id="form">
- <form action="#" method="get" id="registForm">
- <div id="father">
- <div id="form2">
- <table border="0px" width="100%" height="100%" align="center" cellpadding="0px" cellspacing="0px" bgcolor="white">
- <tr>
- <td colspan="2" >
-
- <font size="5">会员注册</font> USER REGISTER
- </td>
- </tr>
- <tr>
- <td width="180px">
-
-
- <label for="user" >用户名</label>
- </td>
- <td>
- <em style="color: red;">*</em> <input type="text" name="user" size="35px" id="user"/>
- </td>
- </tr>
- <tr>
- <td>
-
-
- 密码
- </td>
- <td>
- <em style="color: red;">*</em> <input type="password" name="password" size="35px" id="password" />
- </td>
- </tr>
- <tr>
- <td>
-
-
- 确认密码
- </td>
- <td>
- <em style="color: red;">*</em> <input type="password" name="repassword" size="35px"/>
- </td>
- </tr>
- <tr>
- <td>
-
-
- </td>
- <td>
- <em style="color: red;">*</em> <input type="text" name="email" size="35px" id="email"/>
- </td>
- </tr>
- <tr>
- <td>
-
-
- 姓名
- </td>
- <td>
- <em style="color: red;">*</em> <input type="text" name="username" size="35px"/>
- </td>
- </tr>
- <tr>
- <td>
-
-
- 性别
- </td>
- <td>
- <span style="margin-right: 155px;">
- <em style="color: red;">*</em> <input type="radio" name="sex" value="男"/>男
- <input type="radio" name="sex" value="女"/>女<em></em>
- </span>
- <label for="sex" class="error" style="display: none;"></label>
- </td>
- </tr>
- <tr>
- <td>
-
-
- 出生日期
- </td>
- <td>
- <em style="color: red;">*</em> <input type="text" name="birthday" size="35px"/>
- </td>
- </tr>
- <tr>
- <td>
-
-
- 验证码
- </td>
- <td>
- <em style="color: red;">*</em> <input type="text" name="yanzhengma" />
- <img src="../img/yanzhengma.png" style="height: 18px;width: 85px;"/>
- </td>
- </tr>
- <tr>
- <td colspan="2">
-
-
-
-
- <input type="submit" value="注 册" height="50px"/>
- </td>
- </tr>
- </table>
- </div>
- </div>
- </form>
- </div>
- </div>
- </body>
- </html>
JQuery之validate入门的更多相关文章
- 基于jQuery的Validate表单验证
表单验证可以说在前端开发工作中是无处不在的~ 有数据,有登录,有表单, 都需要前端验证~~ 而我工作中用到最多的就是基于基于jQuery的Validate表单验证~ 就向下面这样~ 因为今天有个朋 ...
- jquery插件开发基础入门
jquery插件开发基础入门 入门 编写一个jquery插件开始于给jquery.fn加入新的功能属性,此处添加的对象属性的名称就是你的插件名称 jQuery.fn,myPlugin = functi ...
- 简单地使用jquery的validate
简单地使用jquery的validate ——@梁WP 摘要:本文通过一个很简单的例子,讲解了jquery validate的最基础使用方式. 一.源代码 注意事项都写在代码的注释里了,哈哈. < ...
- jquery插件-validate
1.引入js,css 下载地址:http://plugins.jquery.com/validate/ 2.设置验证规则:input的class添加以下验证属性 3.设置不符合规则的提示信息:添加da ...
- 使用jquery插件validate制作的表单验证案例
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- jQuery validate入门
<html> <head> <meta charset="utf8"></meta> </head> <body& ...
- jQuery校验validate详解(转)
jQuery校验 官网地址:http://bassistance.de/jquery-plugins/jquery-plugin-validation 一导入js库 <script src=&q ...
- jquery的validate.js 和 form.js 的使用方法
在使用 Jquery 的方法的验证并且修改 原Form 表单的提交方式的时候,需要引用的文件有 <script type="text/javascript" src=&quo ...
- JQuery插件validate的Remote使用
JQuery.validate.js 在表单验证中经常使用,初学,对于其中Remote的使用说明一下. 1. 基本解释 JQuery主要用于DOM树和CSS树的检索和后面的操作的一套方法,JQuery ...
随机推荐
- uc浏览器的用户体验
用户界面: 我认为,uc浏览器的用户界面还是很招人喜欢的,可以很容易让用户找到自己想看的网页.简单快捷. 记住用户的选择: uc在每次用户访问完网站之后都会记住用户访问的高频网站,以便下次用户可以更好 ...
- Python:print()函数的几个常用参数
1.参数sep:设置输出字符产之间的字符串.默认是空格 name='Tomwenxing' age=' job='student' print(name,age,job) print(name,age ...
- 软工1816 · Alpha冲刺(8/10)
团队信息 队名:爸爸饿了 组长博客:here 作业博客:here 组员1(组长):王彬 过去两天完成了哪些任务 推进前后端各个接口的整合 学习jQuery基本语法,为beta阶段的商铺页面做准备 接下 ...
- HDU 5167 Fibonacci 筛法+乱搞
题目链接: hdu: http://acm.hdu.edu.cn/showproblem.php?pid=5167 题意: 给你一个x,判断x能不能由斐波那契数列中的数相乘得到(一个数可以重复使用) ...
- 蜗牛慢慢爬 LeetCode 2. Add Two Numbers [Difficulty: Medium]
题目 You are given two non-empty linked lists representing two non-negative integers. The digits are s ...
- React.js + LiveReload配置详解
一.介绍一下LiveReload: LiveReload monitors changes in the file system. As soon as you save a file, it is ...
- session的基本原理
转载:http://blog.sina.com.cn/s/blog_8155e74d0101iqmh.html 如何严格限制session在30分钟后过期! 1.设置客户端cookie的lifetim ...
- python 小数保留位数
利用round(number[, ndigit] )函数四舍五入 保留浮点数的小数点. 如保留小数点后两位. num = 9.2174 new_num = round( num , 2 ) 则new_ ...
- 【前端学习笔记03】JavaScript对象相关方法及封装
//Object.create()创建对象 var obj = Object.create({aa:1,bb:2,cc:'c'}); obj.dd = 4; console.log(obj.cc); ...
- C++四种类型转化
2018-08-02 (星期四)C++类型转换:static_cast提供编译时期静态类型检测: static_cast <type-id> (expression) 1)完成 ...