Form validation information jquery code

Source: Internet
Author: User

<script type= "Text/javascript" >
$ (function () {
$ ("form:input.required"). each (function () {
var $required =$ ("<strong class= ' High ' >*</strong>");
$ (this). Parent (). append ($required);
});

$ ("Form:input"). blur (function () {
var $parent =$ (this). parent ();
$parent. Find (". Formtips"). Remove ();


Verify User Name
if ($ (this). is (' #username ')) {
if (this.value== "" | | THIS.VALUE.LENGTH&LT;6) {
var errormsg = ' Please enter a username of at least 6 bits ';
$parent. Append (' <span class= ' formtips onError ' > ' +errormsg+ ' </span> ');
}else{
var okmsg= ' input is correct ';
$parent. Append (' <span class= ' formtips onsuccess ' > ' +okmsg+ ' </span> ');
}
}

Verify Mailbox
if ($ (this). is (' #email ')) {
if (this.value== "" | | (this.value!= "" &&!/[email protected]+\. [A-za-z] {2,4}$/.test (This.value))) {//regular validation of mailbox
var errormsg= "Please enter the correct e-mail";
$parent. Append (' <span class= ' formtips onError ' > ' +errormsg+ ' </span> ');
}else{
var okmsg= ' input is correct ';
$parent. Append (' <span class= ' formtips onsuccess ' > ' +okmsg+ ' </span> ');
}
}

});


            //submit validation, ignoring error alerts requires a complete verification of the contents of the form.
            $ (' #send '). Click (function () {
                 $ ("form. Required:input"). Trigger (' blur ');
                var numerror=$ (' form. OnError '). Length
                if (numerror) {
                    return false;
                }
                alert ("Registration is successful, password has been sent to your mailbox, please check.") ");
            });
        });
    </script>

Form validation information jquery code

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.