码迷,mamicode.com
首页 > Web开发 > 详细

jquery-validate.js

时间:2016-05-11 22:00:43      阅读:154      评论:0      收藏:0      [点我收藏+]

标签:

还没正式使用,网上摘下来的。有空再继续仔细看看

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>jquery表单验证</title>
    <script src="js/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
    <!--<script src="js/jquery-2.1.0.js" type="text/javascript" charset="utf-8"></script>-->
    <script src="js/jquery.validate.js" type="text/javascript"></script>
    <link href="css/index.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        $(function () {
            $("#FormTo").validate({
                rules: {
                    uname: "required",
                    pwd: {
                        required: true,
                        rangelength: [4, 20]
                    }
                },
                messages: {
                    uname: "用户名不能为空",
                    pwd: {
                        required: "密码不能为空!",
                        rangelength: "密码最少4个字符,最多20个字符!"
                    }
                },
                highlight: function (element, errorClass, validClass) { //element出错时触发
                    $(element).addClass("inputerror").next().next().show();
                    $(element).removeClass("inputerror").next().next().hide();
                },
                unhighlight: function (element, errorClass, validClass) { //通过的元素加样式  
                    $(element).removeClass("inputerror").next().html("通过").next().hide()
                }, 
                debug: true,
                errorClass: "error",
                errorElement: "span",
                success: "correct"
            });
        });
    </script>
</head>
<body>
<div class="wrapper">
<div class="titleUI"> <h3>用户注册资料</h3></div>

<form id="FormTo" class="democss" action="FormRequest.ashx" method="post">
  <fieldset><legend>用户注册表单</legend>
<div class="formUI">
<p>
<label for="name">用户名:</label><input type="text" class="inputclass w100" id="uname" name="uname" /><span class="msg">用户名必须填写</span>
</p>

<p>
<label for="name">密码:</label><input type="password" class="inputclass w200" name="pwd" /><span class="msg">密码4-20个字符之间</span>
</p>

<p>
<label for="name">确认密码:</label><input type="password" class="inputclass w200" name="pwdTo"  /><span class="msg">密码4-20个字符之dfsafdasdfasdfsaf间</span>
</p>

<p>
<label for="name">真实姓名:</label><input type="text" class="inputclass w200" name="realname"  /><span class="msg">真实姓名必须为字母或汉字 可空</span>
</p>
<p>
<label for="name">新闻内容:</label><textarea rows="5" cols="5" name="content" class="textareaclass w500"></textarea>
</p>
<p>
<label for="name">是否推荐:</label>推荐:<input type="checkbox" name="Top" value="0" /> 特价:<input type="checkbox" name="Top" value="1" /> 新品:<input type="checkbox" name="Top" value="2" />
</p>
<p>
<label for="name">产品分类:</label><select name="category" class="selectUI" >
<option value="1">我们的产品</option>
<option  value="3">客户的产品</option>
<option  value="2">他们的产品</option>
</select>
</p>

<p>
<label for="name">&nbsp;</label><input type="submit" class="submitClass" value="添加" />
</p>

<div class="clear"></div>
</div>
</fieldset>
  </form>
<div id="messageBox"> </div>

</div>
</body>
</html>

 

jquery-validate.js

标签:

原文地址:http://www.cnblogs.com/CyLee/p/5483451.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!