English 中文(简体)
j Query Validate Plugin - Error 信, 在外地有效之后立即删除
原标题:jQuery Validate Plugin - Error messages not removed immediately after field becomes valid

I m trying to use the jQuery Validate plugin on a form like below:

JS:

<script src="jquery-1.7.1.js" type="text/javascript"></script>
<script src="jquery.validate.js" type="text/javascript"></script>
<script>
function ValidateFields() {

    $("#createProgramForm").validate({
        rules: {
            firstname: { required: true, minlength: 2 },
            lastname: { required: true }
        },
        messages: {
            firstname: { minlength: "Minimum 2 characters." },
            lastname: { required: "Please enter a last name." }
        }
    });


    if ($("#createProgramForm").valid()) {
        alert("Form is valid");
    }

}
</script>

传真:

<body>
<div id="page">
    <form id="createProgramForm">
        <p>
            <label for="firstname">
                First Name</label>
            <input name="firstname" id="firstname" type="text" />
        </p>
        <p>
            <label for="lastname">First Name</label>
            <input name="lastname" id="lastname" type="text" />
        </p>
        <p>
            <button onclick="ValidateFields();">Validate</button>
        </p>
    </form>
</div>
</body>

当我点击Validate时,验证错误的信息在田地旁边显示。 但是,一旦实地在时,错误信息就不再有效。 是否有任何人知道这种情况发生?

问题回答

Um,为我工作。 也许会尝试最近的争.。 验证原始吗? 我使用的版本是here





相关问题
submitHandler doesn t work

The following code doesn t work. $(document).ready(function(){ $("#digitalchange").validate( { rules: { addbalance: { digits:true, ...

Dependency mismatch with Jquery Validate plugin

I am pretty new to Jquery, I am using validation rule against my textbox. The problem is when i mark textbox is mandatory n user doesn t input any value then it doesn t show any validation message. I ...

jQuery - Getting custom validation methods to trigger

If I ve added a custom validation method to my form, how can I get it to trigger prior to submit? I m not decorating my form fields but I thought that adding the new method to my rules section would ...

JQuery Validator Plugin

I have managed to implement the validator on a form, and is working fine for all my needs apart from a crucial last one. Does anyone know how I would go about (or whether it s even possible) to ...

JQuery validation plugin - error highlight problem

I have a form with two input textboxes, and I have included jQuery validation rules for both: <script src="../../Scripts/jquery-validate/jquery.validate.js" type="text/javascript"></script&...

热门标签