1

I use JQuery Validation Plugin to validate my form and it works for all fields,
but when I try to use it for <input type="file" id="ProjectInformation">

<script>
    $(function() {
        $("#feedback-form").validate({
            submitHandler: function(form) {
                form.submit();
            },
            rules: {
                Name: {
                    required: true,
                    minlength: 2
                },
                ProjectInformation: {
                    extension: "doc,txt,pdf",
                }
            },
            messages: {
                Name: {
                    required: "Please enter a name",
                    minlength: "Name must consist of at least 2 characters"
                },
                ProjectInformation: {
                    extension: "Only .doc, .txt, and .pdf files allowed",
                }
            }
        });
    });
</script>

I get error Uncaught TypeError: Cannot call method 'call' of undefined
What's wrong?

Community
  • 1
  • 1
Heidel
  • 3,174
  • 16
  • 52
  • 84
  • What's the line that the error refers to? (It's probably in the plugin's js file) – Ofir Baruch May 23 '13 at 09:24
  • Yes, it's here ` } catch(e) { if ( this.settings.debug && window.console ) { console.log( "Exception occurred when checking element " + element.id + ", check the '" + rule.method + "' method.", e ); } throw e; Uncaught TypeError: Cannot call method 'call' of undefined }` – Heidel May 23 '13 at 09:32

1 Answers1

0

I have chacked extension in Validation Plugin and found that in that example they use | instead of , So Try using..

extension: "doc|txt|pdf",
Prashant16
  • 1,514
  • 3
  • 18
  • 39
  • Nope, I tried, it doesnt work too, `The allowed file extensions, seperated via "|" (or a comma, ",")` [link](http://docs.jquery.com/Plugins/Validation/CustomMethods/extension#extension) – Heidel May 23 '13 at 09:29