Я использую jQuery Validate и просмотрел этот форум для ответов, но борюсь с одной частью при добавлении аргумента accept, который он терпит неудачу.jQuery Validating add accept break break code
У меня этот код
$("#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 [о] не определено [Перерыв По этой ошибке]
..., t; for (e = 0; this.errorList [e]; e ++) {var n = this.errorList [e]; if (this.settings.highl ...
выглядит, как вы не добавили 'дополнительный-methods.js' файл, тем' accept' правило определяется там –
ха-ха .. Yepp был глуп :( – Dan
я 'опубликует комментарий как ответ –