我有这样的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 »</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 库 v. 1.9 jquery-1.7.2.min
出于某种原因,“提交”表单仅验证名称输入,要验证电子邮件,我必须对其进行标记。