六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 116|回复: 0

jQuery.validate插件 使用例子

[复制链接]

升级  76%

8

主题

8

主题

8

主题

童生

Rank: 1

积分
38
 楼主| 发表于 2013-2-7 22:53:48 | 显示全部楼层 |阅读模式
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>    <head>        <title>jQuery.validate</title>        <meta http-equiv="pragma" content="no-cache">        <meta http-equiv="cache-control" content="no-cache">        <meta http-equiv="expires" content="0">        <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">        <meta http-equiv="description" content="This is my page">        <script src="/demo/js/jquery-1.4.4.js"></script>        <script type="text/javascript" src="/demo/js/jquery.validate.js"></script>        <script type="text/javascript"><!--    $(document).ready(function(){        $("#test").validate({            rules:{//定义验证规则                pwd:{                    required:true,                    minlength:5,                    maxlength:12                }            },            messages:{//验证显示信息                name:"名字不能为空!",                email:{                    required:"邮箱地址必须填!",                    email:"邮箱地址格式不正确!"                },                pwd:{                    required:"密码不能为空!",                    minlength:jQuery.format("密码最少{0}位!"),                    maxlength:jQuery.format("密码最多{0}位!")                }            }        });    });//--></script><style type="text/css">    body {    font-size: 12px;}</style>    </head>    <body>        <form action="" id="test" method="post">            <fieldset                style="border: 1px solid black; background-color: #AED0EA; -moz-border-radius: 6px 6px 6px 6px; width: 550px;margin: 0px;">                <legend                    style="font-size:14px;border: 1px solid black; background-color: #AED0EA; -moz-border-radius: 3px 3px 3px 3px; font-weight: bold; color: black;">                    jQuery.validate Demo                </legend>                <table>                    <tr>                        <td align="right">                            <label>                                name:                            </label>                        </td>                        <td>                            <input                                style="border: 1px solid black; background-color: #AED0EA; -moz-border-radius: 3px 3px 3px 3px; font-weight: bold; color: black;width: 150px;"                                class="required" name="name">                        </td>                    </tr>                    <tr>                        <td align="right">                            <label>                                email:                            </label>                        </td>                        <td>                            <input                                style="border: 1px solid black; background-color: #AED0EA; -moz-border-radius: 3px 3px 3px 3px; font-weight: bold; color: black;width: 150px;"                                class="email required" name="email">                        </td>                    </tr>                    <tr>                        <td align="right">                            <label>                                password:                            </label>                        </td>                        <td>                            <input type="password"                                style="border: 1px solid black; background-color: #AED0EA; -moz-border-radius: 3px 3px 3px 3px; font-weight: bold; color: black;width: 150px;"                                class="required" name="pwd">                        </td>                    </tr>                    <tr>                        <td align="right">                                                     </td>                        <td>                            <input                                style="border: 1px solid black; background-color: #AED0EA; -moz-border-radius: 3px 3px 3px 3px; font-weight: bold; color: black;"                                class="submit" type="submit" value="submit">                        </td>                    </tr>                </table>            </fieldset>        </form>    </body></html>
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表