I achieved this by following these steps:
1) I have a form:
<form> <textarea required></textarea> <input type="submit" style="display:none;"/> </form> <a>Some other button to trigger event</a>
2) Now we need to check the correctness of filling out the form:
//this is <a> click event: if (!$('form')[0].checkValidity()) { $('form').find('input[type="submit"]').click(); return false; }
This will cause the form to be submitted, but not submit, because there are errors;)
It looks like html5 input errors appear on input [type = "submit"] click :)
Hope will work for you too! :)
source share