jquery validate code example

Example 1: jquery validation plugin

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.2/jquery.validate.min.js"></script>

Example 2: invoking jquery validator

$(document).ready(function () {

    $('#myform').validate({ // initialize the plugin
        // rules & options
    });

    $('#button').click(function() {
        if ($('#myform').valid()) {
            alert('form is valid - not submitted');
        } else {
            alert('form is not valid');
        }
    });

});

Example 3: jquery form validation

function submitFunction(event){
	event.preventDefault();
}
$("#form_id").submit(submitFunction);

Example 4: jquery validate

$("#myform").validate({
  debug: true
});