0

Currently, I'm using http://jqueryvalidation.org/, I have this form

<form action="AddDefectToDatabaseServlet" method="post" id="myForm">

Then in my js script

$(document).ready(function() {

$('#myform').validate({ // initialize the plugin
    rules: {
        title: {
            required: true
        },
        description: {
            required: true
        }
    },
    errorPlacement: function(){
        return false;
    },
    submitHandler: function (form) { // for demo
        alert('valid form submitted'); // for demo
        return false; // for demo
    }
 });

});

but my problem is that even if the validation is wrong, it keeps going to the server side, sorry I'm new to this plugin,

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Chong
  • 59
  • 1
  • 7
  • Possible duplicate of [jquery validation: prevent form submit](http://stackoverflow.com/questions/10305938/jquery-validation-prevent-form-submit) – Gavriel Feb 04 '16 at 01:31

1 Answers1

0

You are missing an invalidHandler.

From the docs - http://jqueryvalidation.org/validate

invalidHandler
Type: Function()
Callback for custom code when an invalid form is submitted. Called with an event object as the first argument, and the validator as the second.
Matt
  • 5,315
  • 1
  • 30
  • 57