1

I would like to find a way to refuse a specific extension in a text field at form submission.

I have a field where you can specify a URL but this URL shouldn't link to a PDF file.

I figured that there is a jQuery validation methods called accept that does exactly the contrary of what I want to do.

Is there a way to use with a not() function or something similar? It would be way easier than creating a custom validation method.

user229044
  • 232,980
  • 40
  • 330
  • 338
Maxime Lepers
  • 59
  • 1
  • 1
  • 6
  • may be you have to create a custom rule for this validation. Check SO link http://stackoverflow.com/questions/9970434/several-custom-validate-rules-in-jquery-validate-plugin – Mahesh KP Apr 19 '12 at 05:20

1 Answers1

2

Here is any idea

var ext = $('#fieldid').val().split('.').pop().toLowerCase();
if($.inArray(ext, ['gif','jpg', ...]) == -1) {
    alert('invalid extension!');
}
Starx
  • 77,474
  • 47
  • 185
  • 261