submit submit in html, if you want to have an onclick click event, and, you also want to validate the form,
If the form is successfully verified, it is fine to execute the onclick event, but if you add the onclick event to the submit button,
The web page will execute the onclick event first, without verifying the form, I looked it up on the Internet, and sent a good js plugin, with the download address below:
Introduce jquery first, then jquery-html5Validate.js
Here's how to use it:
- 示意,假设测试表单id为html5Form,则有:
- $("#html5Form").html5Validate(function() {
- // 全部验证通过,该干嘛干嘛~~
- });
Copy code The effect is as follows:
However, this prompt effect is too ugly, I want to use the prompt effect that comes with HTML5?
- var isIe10 = typeof document.msHidden !== "undefiend";
- $("#html5Form").html5Validate($.noop, {
- novalidate: isIe10 ? false : true
- });
Copy code
The renderings are much more beautiful, with the js script attached:
jquery-html5Validate.js
(17.92 KB, Number of downloads: 2)
|