2

i am using jQuery Validate and have looked through this forum for answers but am struggling with one part when adding the accept argument it fails.

i have this 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();
}); 

the problem is when i save the form (ie validate the form) i get this error

e.validator.methods[o] is undefined [Break On This Error]

...,t;for(e=0;this.errorList[e];e++){var n=this.errorList[e];if(this.settings.highl...

Dan
  • 1,295
  • 2
  • 22
  • 46

1 Answers1

2

looks like you have not added the additional-methods.js file, the accept rule is defined there

Arun P Johny
  • 384,651
  • 66
  • 527
  • 531
  • this doesnt work in IE though? as long as i choose a file it accepts it whereas in FF/chrome it doesnt.. – Dan Aug 27 '13 at 06:10
  • @Dan looks like you are out of luck there... I found another thread with same problem http://forum.jquery.com/topic/validate-plugin-accept-method-not-working-in-ie8 – Arun P Johny Aug 27 '13 at 07:27
  • @Dan it will be much easier to write a validator method yourself in this case – Arun P Johny Aug 27 '13 at 07:28