I have the following view. I like the new HTML5 form validation, and I'd rather keep it. But. I donβt like it when the button is clicked it refreshes the page (submit form).
Instead, I would rather use a button to invoke some AJAX to refresh page elements without refreshing the entire page. However, when I set type="button" , what happens is that HTML5 form validation stops running when the button is clicked.
How can I use HTML5 form validation without triggering page refresh / submit distribution?
Note that I am not interested in the AJAX elements of this problem, just the HTML5 validation issue.
echo "<form>"; echo "<td><input id=\"link_add_title\" type=\"text\" class=\"form-control\" placeholder=\"URL Title\"></td>"; echo "<td><input id=\"link_add_url\" type=\"url\" class=\"form-control\" placeholder=\"Your URL\"></td>"; echo "<td><input id=\"link_add_budget\" type=\"number\" step=\"any\" class=\"form-control\" placeholder=\"Budget\"></td>"; echo "<td><button class=\"btn btn-sm btn-success\"><i class=\"fa fa-check\"></i> Add</button></td>"; echo "</form>";
jquery html5 forms
Amy neville
source share