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.

18
  • @ArcaneCraeda: let me know what part of the post solve the problem. Commented Jan 3, 2016 at 19:18
  • @ArcaneCraeda: And if you read the title you see the asker wanted to manually trigger not showing errors before triggering! Commented Jan 3, 2016 at 19:19
  • @ArcaneCraeda: Already came across that, it doesn't work in my case Commented Jan 3, 2016 at 19:22
  • @ArcaneCraeda: FYI, error message are automatically set according to the user language by ASP.NET resource files. not by using .val() Commented Jan 3, 2016 at 19:23
  • no reason that valid() method shouldn't work. Need to explain why it doesn't Commented Jan 3, 2016 at 19:24

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.