Jquery implements Simple Form Verification _ jquery-js tutorial

Source: Internet
Author: User
This article mainly introduces jquery to implement simple form verification. The idea is to first add a required mark for each required and implement it using the each () method, if you are interested, you can refer to jquery's implementation of simple form verification. Let's first share with you the Implementation ideas.

General idea:
Add a required flag for each required.Each ()Method.
In the each () methodCreate an element,ThenAppend () methodAdd the created element to the end of the parent element.
HereThisEach time this corresponds to the corresponding input element, and then gets the corresponding parent element.
ThenInputElement addition loss focus event. Then, verify the user name and email.
Here we useJudge is ()If it is a user name, perform corresponding processing, and if it is an email, perform corresponding verification.
In the jQuery framework, you can also insert original javascript code. For exampleThis. value, and this. value. length.Determine the content.
Then, the email is verified andRegular Expression.
Then addKeyup eventAndFocus eventThat is, verification is also required during keyup. You can call the blur event. TriggerHandler () trigger is used to trigger the corresponding event.
At last, perform unified verification when submitting the form to handle the whole and details.
If required, addRed Star logo.

JQuery section:

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.