我在项目中不像 $(sth)validate{} 那样做某事,它的工作方式与我预期的一样,但在另一个项目中,我只能看到一个验证错误消息,第一个,然后我填写它,然后单击提交按钮,它不检查其他输入:
我自己的功能如下,我可以在输入“名字”的值后看到“这里”,但如果我不输入中间名和姓氏,我需要错误消息。
function assembleAndSaveContact(){
if($("form#form_validation_reg_generate_contact").valid()){
console.log('here');
}
}
xhtml代码:
<!-- validation -->
<script src='#{applicationBean.resourcePath}/admin/lib/validation/jquery.validate.min.js'></script>
<!-- sticky messages -->
<script src='#{applicationBean.resourcePath}/admin/lib/sticky/sticky.min.js'></script>
<script src="#{applicationBean.resourcePath}/admin/bootstrap/js/bootstrap.min.js"></script>
<li><a onclick="assembleAndSaveContact();" class="btn-mini" href="#" style="float: left;"><i class="splashy-mail_light_new_2"></i>Save and Close </a></li>
<fieldset>
<form id="form_validation_reg_generate_contact">
Profile
<div style="clear: both; height: 1px; background: #CCCCCC;margin-bottom: 6px; margin-top: 6px">
</div>
<div class="control-group" style="margin-bottom: 6px">
<div class="span4" style="margin: 0px">
<label class="control_label_compose"><a data-toggle="modal" href="#adrBook">First Name</a></label>
</div>
<div class="span8" style="margin: 0px">
<input class="span12 required" type="text" id="firstName"/>
</div>
</div>
<div class="control-group" style="margin-bottom: 6px">
<div class="span4" style="margin: 0px">
<label class="control_label_compose"><a data-toggle="modal" href="#adrBook">Middle Name</a></label>
</div>
<div class="span8" style="margin: 0px">
<input class="required span12" type="text" id="middleName"/>
</div>
</div>
<div class="control-group" style="margin-bottom: 6px">
<div class="span4" style="margin: 0px">
<label class="control_label_compose"><a data-toggle="modal" href="#adrBook">Last Name</a></label>
</div>
<div class="span8" style="margin: 0px">
<input class="span12 required" type="text" id="lastName"/>
</div>
</div>
</form>
</fieldset>