The project uses the jquery form check plugin validate, have been just doing a very simple checksum, has not done a slightly complex application, the recent project requirements for the application increased, a page has two submit buttons, and then the form checksum is bound to the button click event, as follows.
Then it's natural to use the valid () function of the plugin:
This actually achieves the desired effect, but there is a problem in the IE8, the valid () method always returns false, and all the fields will be checked as a required field, tangled for a long time, because the jquery plug-in code is very complex, so just start to see a special effort, and then one step after the investigation, Found the problem, the problem is on the Attributerules () function:
The function is: when you write the validation rules on the page rather than in the script, you can also apply the validation framework. Technically is very reasonable, the treatment of required is also reasonable, but for IE8, there is a problem. IE8 will perform the following branches:
Therefore, all fields are validated as required fields. After testing, the last two methods can be solved:
The first is to find the following code in the Rules () method, and comment out the call to Attributerules (), because it is very rare to write the checksum to the page, which is certainly not the best solution, then look at the second kind.
The second solution needs to do two things: first, you need to make some changes to the Attributerules () method, and replace the GetAttribute () method with the attr () method. Note that getattribute () is a JS method, and attr () is a jquery method, they use the object is not the same, in fact, after the change, IE8 the following bug has been resolved, but IE7 under the problem, so you want to use the latest jquery, I used the jquery1.10.2 version when I tested it.
Oh, by the end, don't forget to block the default event for a form.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.