首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >jquery:密码和确认密码

问jquery:密码和确认密码
EN

Stack Overflow用户
提问于 2013-05-07 12:12:17
回答 1查看 797关注 0票数 0

我正在对文本框使用jquery插件。在我的其他文本框中,当我为我的一些文本框提供详细信息时,插件工作fine...but。

下面是我的代码:

代码语言:javascript
复制
    jQuery("#Merchant_Registration").validate({
                rules: {
                    UserN: "required",
                    pass: {
                        required: true,
                        minlength: 5
                    },
                    confirm: {
                        minlength: 5,
                        equalTo: "#Password",
                    },
                    question: "required",
                    answer: "required"
                },
                success: function () {
                    xval = true;
                },
                messages: {
                    UserN: "Please enter your last name",
                    pass: {
                        required: "Provide a password",
                        minlength: "Password length at least 5 characters!"
                    },
                    confirm: {
                        minlength: "Password length at least 5 characters!",
                        equalTo: "Enter the same password as above"
                    },
                    question: "Please enter a security question",
                    answer: "Please enter answer to security question"
                }
            });

            if (jQuery("#Merchant_Registration").valid()) {
                return true;
            }

这是我的标记代码:

代码语言:javascript
复制
<p>
                <label>Username:</label>
                <span class="field">
                <asp:TextBox ID="UserName" class="required" runat="server" name="UserN"></asp:TextBox>
                </span>
                </p>

                <p>
                <label>Password:</label>
                <span class="field">
                <asp:TextBox ID="Password" class="required" runat="server" name="pass"></asp:TextBox>
                </span>
                </p>

                <p>
                <label>Re-type Password:</label>
                <span class="field">
                <asp:TextBox ID="Password2" class="required" runat="server" name="confirm"></asp:TextBox>
                </span>
                </p>

                <p>
                <label>Security Question:</label>
                <span class="field">
                <asp:TextBox ID="SecurityQ" class="required" runat="server" name="question"></asp:TextBox>
                </span>
                </p>

                <p>
                <label>Security Answer:</label>
                <span class="field">
                <asp:TextBox ID="SecurityA" class="required" runat="server" name="answer"></asp:TextBox>
                </span>
                </p>

在我的密码字段中,它不检查用户输入是否是same...and不显示消息。

而其他文本框,当单击下一步按钮时,显示的错误是“此字段是必需的”,而不是预先设置的消息...

谁能帮你me..thank你..

EN

回答 1

Stack Overflow用户

发布于 2013-05-07 12:27:00

您需要为验证器使用name属性

例如:

代码语言:javascript
复制
<form id="Merchant_Registration">
    <p>
        <label>Username:</label>
        <span class="field">
            <input ID="UserName" name="UserN"/>
        </span>
    </p>

    <p>
        <label>Password:</label>
        <span class="field">
            <input ID="Password" name="Password"/>
        </span>
    </p>

    <p>
        <label>Re-type Password:</label>
        <span class="field">
            <input ID="Password2" name="Password2"/>
        </span>
    </p>

    <p>
        <label>Security Question:</label>
        <span class="field">
            <input ID="SecurityQ" name="SecurityQ"/>
        </span>
    </p>

    <p>
        <label>Security Answer:</label>
        <span class="field">
            <input ID="SecurityA" name="SecurityA"/>
        </span>
    </p>
</form>

演示:Fiddle

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16411083

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档