jQuery Validate extension method not working
jquery, jquery-validate
Solution
That's because the `extension` rule/method is not part of the jQuery Validate plugin by default.
You must include the jQuery Validate plugin's `additional-methods.js` file if you want to use the `extension` rule.
It seems to be working now...
http://jsfiddle.net/tMRer/
Problem
I am adding the rule below to an existing jQuery Validate script using `extension`, but this snippet causes it to break and not validate at all. I have tried every possible combination of commas before and after, and I have also tried using the `accept` method with mimetypes, but nothing thus far has worked. If I comment out this snippet (and the comment on the line before it), the code works perfectly, but adding this in causes it to break. Here's a jsFiddle with the code as-is (doesn't work), and here's one with exactly the same code except the snippet is commented out (works fine). The snippet itself: ``` form1upload: { extension: "jpg|jpeg|pdf|doc|docx|png" } ``` The full code: ``` jQuery(document).ready(function() { jQuery("#grantapp").validate({ errorClass:"errorlabels", rules: { form1name: "required", form1building: "required", form1position: "required", form1phonex: "required", form1besttime: "required", form1projtitle: "required", form1benefit: "required", form1timeframe: "required", form1relevance: "required", form1description: "required", form1amount: "required", form1acceptchk: "required", form1upload: { extension: "jpg|jpeg|pdf|doc|docx|png" } }, messages: { form1name: "You must enter your name.", form1building: "You must enter your building.", form1position: "You must enter your position.", form1phonex: "You must enter your phone extension.", form1besttime: "You must enter the best time to contact you.", form1projtitle: "You must give your project a title.", form1benefit: "You must enter the number of students who will benefit.", form1timeframe: "You must enter a time frame for this project.", form1relevance: "<br />You must state how this project is relevant to education.", form1description: "<br />You must provide a description of your project.", form1amount: "You must enter a requested amount.", form1acceptchk: "<span style=\"position:relative;top:-10px;\">You must accept the terms.</span>", form1upload: "You may not upload this type of file." }, errorPlacement: function (error, element) { if (element.attr("name") == "form1acceptchk") { error.insertAfter("#tbl1"); } else { error.insertAfter(element); } } }); }); ```