我有一个表单,可以在每个字段模糊事件中保存记录,但是每当我为文件字段选择文件时,它都会保存记录,这是错误的,因为我希望它仅适用于“模糊”事件。
代码:
jQuery(document).on("blur", ":input[type!='button']", function() {
alert('hi');
});
它使我警惕选择字段值。所有其他输入类型均可与此事件一起正常工作。
HTML代码:
<div class="form-group">
<div class="col-sm-4 control-label">
<label id="jform_com_tjucm_test_for_draft_FirstName-lbl" for="jform_com_tjucm_test_for_draft_FirstName">
First Name</label>
</div>
<div class="col-sm-8">
<input type="text" name="jform[com_tjucm_test-for-draft_FirstName]" id="jform_com_tjucm_test_for_draft_FirstName" value="" aria-invalid="false">
</div>
</div>
<div class="form-group">
<div class="col-sm-4 control-label">
<label id="jform_com_tjucm_test_for_draft_New-lbl" for="jform_com_tjucm_test_for_draft_New">
Image</label>
</div>
<div class="col-sm-8">
<input type="file" name="jform[com_tjucm_test-for-draft_New]" id="jform_com_tjucm_test_for_draft_New" size="32" accept=".png,.jpeg,.jpg" class="validate-filetype"><br>
Maximum upload size: <strong>32.00 MB</strong>
</div>
</div>
<div class="form-group">
<div class="col-sm-4 control-label">
<label id="jform_com_tjucm_test_for_draft_CalendarField-lbl" for="jform_com_tjucm_test_for_draft_CalendarField">
Calendar Field</label>
</div>
<div class="col-sm-8">
<div class="field-calendar">
<div class="input-append">
<input type="text" id="jform_com_tjucm_test_for_draft_CalendarField" name="jform[com_tjucm_test-for-draft_CalendarField]" value="" class="calendar-textfield-class" data-alt-value="" autocomplete="off">
</div>
</div>
</div>
答案 0 :(得分:0)
尝试:
jQuery(document).on("blur", "input:not([type='button'])", function() {
alert('hi');
});