haacked / aspnet-client-validation

A client validation library for ASP.NET MVC that does not require jQuery

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to manually check if the form is valid?

dotnetshadow opened this issue · comments

Hi there,

Firstly a great library well done, I was wondering how do you go about checking if a form is valid from javascript?
Basically I have a need to only do something once the form is valid. With jquery validate it had the .valid() method, is there something similar?

Figured it out thanks

What was it? I should add it to the README.

document.getElementById('form').addEventListener('validation', function (e) { 
    const isValid = e.detail.valid;
    ...
});

I didn't realise that I can subscribe to the event, I only noticed it when looking through the commits

There is an isValid function but this is missing from the non-minified file in the release zip, along with some other functions - the minified version seems fine. I had to pull down the files from the dist folder to get this working. Could there be an issue with the build/release process that is stripping these out? Do you want me to raise this as a separate issue?