javascript how to check if a from is valid which has inputs with required attribute using javascript Edit

Murugan Andezuthu Dharmaratnam | 09 December 2020 | 216

In my application have a form with several input elements with the required attribute. How can I check if the form is valid using javascript

Solution

you can use the checkValidity function in javascript to check if the from is valid.

document.getElementById("contactform").checkValidity()

If you want to do the same using jquery use the code below
$("#contactform")[0].checkValidity()