I must have missed something.
I have a form:
<form action="/" method="post">
<input type="text" name="field" required />
<input type="submit" value="Submit" />
</form>
And I want to add a special behavior when then user clicks on the submit
button without filling the required
field. I have jQuery so my intuition wrote:
$('form').on('submit', function(e){
console.log('Adding special behavior');
});
but this is not triggered. Looked for $('form').on('validate')
or something, but could not find anything.
Ain't there any event triggered at this step? Do I have to remove the required
and handle all the validation manually? That would be surprising!
Thanks
EDIT: this is no duplicate of this question since I don't (want to) use jquery.validate.js
and my question doesn't rely on jQuery (I happen to use it but this simply helps for clarity). It's the HTML5 behavior that I wanted to clarify.