Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trigger jQuery Validation Manually?

I have i form i submit via jQuery's .submit(), unfortunately it does not trigger the validation plugin when i do it this way. If i place a submit button inside the form, it works perfectly.

Is there someway to trigger the plugin manually?

Thanks in advance.

like image 317
Mikkel Avatar asked Jun 19 '11 19:06

Mikkel


People also ask

How do you check whether a form is valid or not in jQuery?

$("#form_id"). valid(); Checks whether the selected form is valid or whether all selected elements are valid. validate() needs to be called on the form before checking it using this method.

What is jQuery validate unobtrusive?

Unobtrusive Validation means without writing a lot of validation code, you can perform simple client-side validation by adding the suitable attributes and including the suitable script files. These unobtrusive validation libraries need to be added: jquery.validate.min.js.

What is validation in jQuery?

Form validation is a process of confirming the relevant information entered by the user in the input field. Here we will be validating a simple form that consists of a username, password and a confirmed password using jQuery. Prerequisites: You must be aware of the basics of HTML, CSS, JavaScript, and jQuery.


1 Answers

$("#myButton").click(function(e) {
    e.preventDefault();
    if($("#myform").valid()){
        // the form is valid, do something
    } else{
        // the form is invalid
    }
});
like image 62
Shef Avatar answered Oct 06 '22 01:10

Shef