Form validation

How to check form fields on submit button using jquery?

+3
source share
1 answer

The jQuery.validate plugin is the best solution I've found.

All you have to do is provide the input to the required class, and then call .validate () on the form in your document. Now call for example.

$(function() { 
    $('#idofyourform').validate();
});

You can also use email and other types of validation using the same method. The plugin also extends your own rules.

Remember that you will also need to check either side of the data server.

Edit: Reply to comment

To check only when submitting the form, add the following parameter:

$("#idofyourform").validate({
   onsubmit: true,
   onkeyup: false,
   onfocusout: false,
   onclick: false
})

.

+3

Source: https://habr.com/ru/post/1756082/


All Articles