我正在使用 jQuery Validate 并查看了这个论坛的答案,但是在添加失败的接受参数时我正在努力解决其中的一个问题。
我有这个代码
$("#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] 未定义 [Break On This Error]
...,t;for(e=0;this.errorList[e];e++){var n=this.errorList[e];if(this.settings.highl...