Share some JavaScript applications during Member registration on the self-developed web platform

Source: Internet
Author: User
Tags valid email address

When developing a web platform, you will always encounter some input judgments or restrictions on some special characters. Recently, I have been busy developing my own web platform (www.sanyalanhua.com, a self-developed web platform, as mentioned earlier). In the Membership registration system, I used JavaScript to make judgments on the browser .. For example, if you enter a password when registering a member, you must ignore other characters when specifying that the password can only contain numbers, letters, and uppercase/lowercase letters ..CodeIs

<Script language = "JavaScript">

Function fucpwdchk (STR)
{
VaR strsource = "0123456789 abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz ";
VaR ch;
VaR I;
VaR temp;

For (I = 0; I <= (Str. Length-1); I ++)
{

Ch = Str. charat (I );
Temp = strsource. indexof (CH );
If (temp =-1)
{
Return 0;
}
}
If (strsource. indexof (CH) =-1)
{
Return 0;
}
Else
{
Return 1;
}
}

Function checkreg ()

{If (! Fucpwdchk (document. adduser. cuspwd. Value )){
Alert ("prompt: only numbers and uppercase and lowercase letters can be used as passwords ");
Document. adduser. cuspwd. Focus ();
Return false;
}

}

</SCRIPT>

 

When we want to enter some contact information, such as the contact number, email address, and QQ, during the Member registration process, we have to filter out the input results when only numbers and email addresses are allowed for the contact phone number, which must comply with the mailbox format and QQ number, and only numbers are allowed... Javascript can be used directly on the browser side to determine whether or not .. The code is

<Script language = "JavaScript">
Function fucphochk (STR)
{
VaR strsource = "0123456789 ";
VaR ch;
VaR I;
VaR temp;

For (I = 0; I <= (Str. Length-1); I ++)
{

Ch = Str. charat (I );
Temp = strsource. indexof (CH );
If (temp =-1)
{
Return 0;
}
}
If (strsource. indexof (CH) =-1)
{
Return 0;
}
Else
{
Return 1;
}
}

Function checkreg ()
{

If (! Fucphochk (document. adduser. custel. Value )){
Alert ("Note: Only pure numbers can be used as mobile phone numbers ");
Document. adduser. custel. Focus ();
Return false;
}

If (! Document. adduser. cusemail. value. Match (/^. + @. + $ /)){
Alert ("prompt: enter a valid Email Address ");
Document. adduser. cusemail. Focus ();
Return false;
}

}

</SCRIPT>

For example, see the registered member in my self-developed web platform www.sanyalanhua.com .. Various comments are posted on specific applications, so that you can share and learn together ..

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.