How to raise a callback when ASP.NET MVC client validation fails

Total Post:24

Points:168
 660  View(s)
Ratings:
Rate this:

Hi!!

I am using ASP.NET MVC 5 with jquery.  I need to handle an event when the client side validation fails.

I tried this but got failure:

$("#myform").bind("invalid-form.validate",
function () 
{
alert('invalid!'); }
);

 Thanks

  1. Post:52

    Points:366
    Re: How to raise a callback when ASP.NET MVC client validation fails

    Hi Ailsa,

    According to your description, I suggest you could use valid function to check if current input value is valid or not after the input element lost focus.

    I am providing to a script please check it May it helps you..

      $('input').focusout(function () {
            var currInput = this;
            if (!$(currInput).valid()) {
                console.log("invalid!");
            }
        });

      Modified On Apr-11-2018 10:36:58 PM
  1. Post:24

    Points:168
    Re: How to raise a callback when ASP.NET MVC client validation fails

    thanks Manish for your help...


    My problem is solved.

Answer