7, JS using regular expression validation

Source: Internet
Author: User

1 <!DOCTYPE HTML Public "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/TR/xhtml1/DTD/ Xhtml1-transitional.dtd ">2 <HTMLxmlns= "http://www.w3.org/1999/xhtml">3 <Head>4 <Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8" />5 <title>Regular expressions for form validation</title>6 7 </Head>8 9 <Body>Ten  One     <fieldsetstyle= "width:400px;"> A         <legend>XXX website Registration</legend>   -              -                <Table> the                   <TR> -                     <TD>User name:</TD> -                     <TD><inputtype= "text"ID= "User"/><span></span></TD> -                   </TR> +                   <TR> -                     <TD>Password:</TD> +                     <TD><inputtype= "Password"ID= "pwd"onblur= "Pwdblur ()"onfocus= "Pwdfocus ()"/><span></span></TD> A                   </TR> at                   <TR> -                     <TD>Confirm Password:</TD> -                     <TD><inputtype= "Password"ID= "Repwd"/><span></span></TD> -                   </TR> -                   <TR> -                     <TD>Mailbox:</TD> in                     <TD><inputtype= "text"ID= "Email"/><span></span></TD> -                   </TR> to                   <TR> +                     <TD><inputtype= "Submit"value= "Register"/></TD> -                     <TD><inputtype= "Reset"value= "Reset"/></TD> the                   </TR> *                 $                </Table>Panax Notoginseng              -     </fieldset> the  + <Scripttype= "Text/javascript"> A   functionPwdfocus () { the        +      varpwd=document.getElementById ("pwd"); - Pwd.style.border="1px Blue Solid";  $ Pwd.nextSibling.innerHTML="Password length must be 6 to"; $   } -   functionPwdblur () { -      varpwd=document.getElementById ("pwd"); the      //get the Value property 1 -      //var pwdval=pwd.getattribute ("value");Wuyi       the      //Get the Value property 2 -      varPwdval=Pwd.value; Wu      varReg=/^[a-za-z0-9]{6,12}$/; -      if(Reg.test (pwdval)==false){ About Pwd.style.border="1px Red Solid";  $ Pwd.nextSibling.innerHTML="Password length must be 6 to"; -      }Else{ - Pwd.style.border="1px Green Solid";  - Pwd.nextSibling.innerHTML="Password Available"; A     } +    the   } - </Script> $ </Body> the </HTML>

7, JS using regular expression validation

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.