jQuery.validate插件 使用例子

<!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">
                            &nbsp;
                        </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>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值