我正在使用jQuery Validate并查看了这个论坛的答案,但在添加accept参数失败时,我正在努力解决一个问题。
我有这个代码
$("#addNewDocumentForm").validate({
rules: {
inputDocument: { required: true, accept: "png|jpe?g|gif|pdf" }
},
messages: {
inputDocument: "File must be PDF, DOCX, JPG, GIF or PNG, less than 1MB"
},
submitHandler: function(e) {
/* stop form from submitting normally */
event.preventDefault();
/* get some values from elements on the page: */
var $form = $("#addNewDocumentForm"),
inputDocument = $('#inputDocument').val();
url = $form.attr( 'action' );
/* Send the data using post */
var posting = $.post( url, { inputDocument: inputDocument} );
/* Put the results in a div */
posting.done(function( data ) {console.log(data) });
posting.fail(function() { alert("This document could not be added at this current time."); })
}
});
$('#saveDocument').on('click', function(e){
$('#addNewDocumentForm').submit();
});
问题是当我保存表单(即验证表单)时,我收到此错误
e.validator.methods [o]未定义 [打破此错误]
...,t; for(e = 0; this.errorList [e]; e ++){var n = this.errorList [e]; if(this.settings.highl ...