0

I got a form in which I'm using unobtrusive jquery validation and I just wanted to save myself the trouble of creating custom client side validation attributes for checking input file size and captcha since I'm not reusing them anywhere else.

The problem is if I do the onclick="return formValidation();" all will be fine but the captcha and file size error appear before the jquery validation since the form is not posted and is actually prevented from being posted as the function returns false. But I want all errors to be shown at the same time. So I do

function formValidation(){
      $validator.showError() // put here on purpose to test if it is blocking
      return checkCaptcha() && checkFileSize() == true;
 }

I see that nothing can be executed after the '$validator.showError()". Since I'm not a JQuery and JavaScript enthusiast I gotta admit that I just find the $validator.showError() in an accepted answer in StackOverFlow so I'm unsure if it is actually correct. Looking for the solution.

Arnold Zahrneinder
  • 4,788
  • 10
  • 40
  • 76

0 Answers0