验证不会立即开始......而不是完全开始

时间:2012-08-30 18:27:09

标签: jquery jquery-validate

我有这样的HTML:

                <form action="" id="emailFillOutForm">
                <div class="txt-fld">
                    <label for="repName">Rep. Name</label>
                    <input id="repName" type="text" disabled="disabled" value="John Smith" class="disabled" /> <!-- This value will come from login, fake it for now -->
                    <label for="financedAmount" style="padding-left: 15px;">Financed Amount</label>
                    <input id="financedAmount" type="text" disabled="disabled" class="disabled" />
                </div>
                <div class="txt-fld">
                    <label for="doctorName">Doctor Name</label>
                    <input id="doctorName" type="text" class="required"/>
                    <label for="emailAddress" style="padding-left: 15px;">Email address</label>
                    <input id="emailAddress" type="text" class="required email"/>
                </div>
                <div class="txt-fld">
                    <label>Equipment</label>
                    <select name="equipment" class="required">
                        <option value="Equipment1" selected="selected">Equipment1</option>
                        <option value="Equipment2">Equipment2</option>
                    </select>
                </div>
                <div class="btn-fld">
                    <button type="submit" value="submit">Submit &raquo;</button>
                </div>
             </form>

Javascript如下:

    // Validate submit form with the jQuery validation library
        $("#emailFillOutForm").validate({
            errorPlacement: function (error, element) {
                error.appendTo($(element.parent("div")));
            },
            rules: {
                emailAddress: {
                    required: true,
                    email: true
                }
            }
        });

jquery.validate.min.js library v.1.9 的jquery-1.7.2.min

出于某种原因,“提交”表单只会验证输入的名称,以便验证电子邮件,我必须在其上进行选项卡。

1 个答案:

答案 0 :(得分:1)

您需要添加的所有内容都是name属性,其值与id相同。

[...]

<input id="doctorName" name"doctorName" type="text" class="required"/>

[...]

<input id="emailAddress" name="emailAddress" type="text" class="required email"/>

[...]