Ajax registered users do not need to automatically verify the code and call code

Source: Internet
Author: User
The following is the JS Code to be used. Generally, a separate JS file is put, and this example is placed in myjs. the following code references the file in the JS file: <script language = "JavaScript" src = "myjs. the JS "type =" text/JavaScript "> </SCRIPT> code is as follows:

VaR icon = ' ';
VaR NS = ["loginname", "password", "passw", "mail", "companyName", "tel", "fax", "dizhi", "Zip ", "linkname", "Shouji", "url", "jieshao", "yanzheng"];

// Change the image
Function setimage (){
//
VaR rod = math. Round (math. Random () * 100 );
$ ('Imayanzhen'). src = "image/loading.gif ";//
$ ('Imayanzhen'). src = "validatecode. aspx? Id = "+ rod;
}

Function checkusr (s ){
VaR MA = ["User Name (4-16 digits )! "," The user name is composed of numbers, English letters, underscores, and hyphens! "];
If (! Limitlen (S, 4, 16 )){
Showinfo ("loginname", ma [0]);
Return false;
}
If (! HasAccountChar (s )){
ShowInfo ("Loginname", ma [1]);
Return false;
}
ShowInfo ("Loginname ");
Return true;
}

Function isLoginname (s)
{
Var ma = ["User Name (4-16 digits )! "," The user name is composed of numbers, English letters, underscores, and hyphens! "," This user name has been registered. Please change it to another one. "," Please wait, loading data... "];
Var icons = ' ';

If (! LimitLen (s, 4, 16 )){
ShowInfo ("Loginname", ma [0]);
Return false;
}
If (! Hasaccountchar (s )){
Showinfo ("loginname", ma [1]);
Return false;
}

$ ("Tisiloginname"). classname = "Focus ";
$ ("Loginnameinfo"). innerhtml = icons + ma [3];

VaR Bret = join. getreturncode (s). value;
If (bRet = "1 "){
$ ("TisiLoginname"). className = "error ";
$ ("LoginnameInfo"). innerHTML = icon + ma [2];
}
Else
{
ShowInfo ("Loginname ");
}
}

Function checkPwd (s ){
Var ma = ["password (6-20 digits )! "," The password cannot contain Chinese characters or fullwidth symbols! "," The two passwords are inconsistent! "];
If (! LimitLen (s, 6, 16 )){
ShowInfo ("Password", ma [0]);
Return false;
}
If (hasChineseChar (s )){
ShowInfo ("Password", ma [1]);
Return false;
}
ShowInfo ("Password ");
Return true;
}

Function checkPwd2 (s ){
Var ma = ["password (6-20 digits )! "," The password cannot contain Chinese characters or fullwidth symbols! "," The two passwords are inconsistent! "];
If (! LimitLen (s, 6, 16 )){
ShowInfo ("Passw", ma [0]);
Return false;
}
If (hasChineseChar (s )){
ShowInfo ("Passw", ma [1]);
Return false;
}

If (s = trim ($ ("TexPassword"). value ))
{
ShowInfo ("Passw ");
Return true;
}
Else {
ShowInfo ("Passw", ma [2]);
Return false;
}
}

Function checkEml (s ){
Var ma = ["Enter frequently used emails! "," The email format is incorrect! "];
If (s. length <5 ){
ShowInfo ("Mail", ma [0]);
Return false;
}
If (! IsEmail (s )){
ShowInfo ("Mail", ma [1]);
Return false;
}
ShowInfo ("Mail ");
Return true;
}

Function checkCompany (s ){
Var ma = ["enterprise name cannot be blank! "];
If (! LimitLen (s, 1,100 )){
ShowInfo ("Companyname", ma [0]);
Return false;
}
ShowInfo ("Companyname ");
Return true;
}

Function checkphone (){
VaR MA = ["The Country dialing code cannot be blank! "," The telephone area code cannot be blank! "," Incorrect phone number! "];
VaR GJ = $ ("textelgj"). value;
VaR QH = $ ("textelqh"). value;
VaR S = $ ("textel"). value;
If (gj. Length = 0 ){
Showinfo ("tel", ma [0]);
Return false;
}
If (Qh. Length = 0 ){
Showinfo ("tel", ma [1]);
Return false;
}
If (! IsPhone (gj + "-" + qh + "-" + s )){
ShowInfo ("Tel", ma [2]);
Return false;
}
ShowInfo ("Tel ");
Return true;
}

Function checkFax (){
Var ma = ["The Country Fax Code cannot be blank! "," The fax Area Code cannot be blank! "," The fax number is incorrect! "];
Var gj = $ ("TexFaxGJ"). value;
Var qh = $ ("TexFaxQH"). value;
Var s = $ ("TexFax"). value;

If (gj. length = 0 & qh. length = 0 & s. length = 0)
{
$ ("TisiFax"). className = "lond ";
$ ("FaxInfo"). innerHTML = "";
Return true;
}
If (gj. length = 0 ){
Showinfo ("fax", ma [0]);
Return false;
}
If (Qh. Length = 0 ){
Showinfo ("fax", ma [1]);
Return false;
}
If (! Isphone (GJ + "-" + qH + "-" + S )){
Showinfo ("fax", ma [2]);
Return false;
}
Showinfo ("fax ");
Return true;
}


Function checkDizi (s ){
Var ma = ["The enterprise address cannot be blank! "];
If (! LimitLen (s, 1,100 )){
ShowInfo ("Dizhi", ma [0]);
Return false;
}
ShowInfo ("Dizhi ");
Return true;
}

Function checkZip (s ){
Var ma = ["Incorrect zip code format! "];
If (s. length = 0 ){
$ ("TisiZip"). className = "lond ";
$ ("ZipInfo"). innerHTML = "users in China must enter the Standard 6-digit zip code. ";
Return true;
}
If (! Iszip (s )){
Showinfo ("Zip", ma [0]);
Return false;
}
Showinfo ("Zip ");
Return true;
}

Function checkshengfen (){
VaR MA = ["select the province where your company is located! "," Select the city where your company is located! "];
Var sh, qu;
Sh = $ ("DropShengfen"). selectedIndex;
Qu = $ ("DropDiqu"). selectedValue;
If (sh = 0 ){
ShowInfo ("Shengfen", ma [0]);
Return false;
}
If (qu = ""){
Showinfo ("shengfen", ma [1]);
Return false;
}
Showinfo ("shengfen ");
Return true;
}

Function checklinkname (s ){
VaR MA = ["contact cannot be blank! "];
If (! Limitlen (S, 2, 20 )){
Showinfo ("linkname", ma [0]);
Return false;
}
ShowInfo ("Linkname ");
Return true;
}

Function checkShouji (s ){
Var ma = ["Incorrect mobile phone format! "];
If (s. length = 0 ){
$ ("TisiShouji"). className = "lond ";
$ ("ShoujiInfo"). innerHTML = "we recommend that you enter this information so that potential customers can contact you in time! ";
Return true;
}
If (! IsMobile (s )){
ShowInfo ("Shouji", ma [0]);
Return false;
}
ShowInfo ("Shouji ");
Return true;
}

Function checkUrl (s ){
Var ma = ["The URL format is incorrect! "];
If (s = "HTTP: //" | s. length = 0 ){
$ ("Tisiurl"). classname = "Lond ";
$ ("Urlinfo"). innerhtml = "add http: // before the URL ://. ";
Return true;
}
If (! Isurl (s )){
Showinfo ("url", ma [0]);
Return false;
}
Showinfo ("url ");
Return true;
}

Function checkJieshao (s ){
Var ma = ["enterprise introduction cannot be blank! "];
If (! LimitLen (s, 1,2000 )){
ShowInfo ("Jieshao", ma [0]);
Return false;
}
ShowInfo ("Jieshao ");
Return true;
}


Function checkYanzheng (s ){
Var ma = ["The Verification Code cannot be blank! "," The verification code is a four-character letter or number! "," Incorrect verification code. Please enter it again! "];
If (s. length = 0)
{
Showinfo ("yanzheng", ma [0]);
Return false;
}
If (S. Length <4)
{
Showinfo ("yanzheng", ma [1]);
Return false;
} Else {
VaR ses = join. Sessions (). value;
If (S. tolowercase ()! = SES)
{
Showinfo ("yanzheng", ma [2]);
Return false;
}
}
Showinfo ("yanzheng ");
Return true;
}

Function inputfocus (n, I)
{
Var ma = ["4-16 digits; only digits (0-9) and English (a-z) are allowed, case-insensitive. We recommend that you use the company name for short. ",
"6-20 characters, case sensitive, cannot be the same as the user name. We recommend that you use English letters (a-z) and numbers (0-9) to make it easier to remember and guess. ",
"Enter the password entered above again. ",
"Please fill in the frequently used email address. This is a way for the customer to contact you! ",
"Enter the full name of your company in Chinese. ",
"Very important! This is the main method for customers to contact you! ",
"Enter the complete company address. ",
"Users in China must enter the Standard 6-digit postal code. ",
"Select the province and city where the company is located. ",
"Enter the real name of the contact. ",
"We recommend that you enter this information so that potential customers can contact you in time! ",
"Add: HTTP: // before the URL ://. ",
"You can enter a maximum of 2000 characters for enterprise introduction. ",
"Enter the verification string displayed on the left (case-insensitive ). "];
Var fdo = $ ("Tisi" + n );
Var ido = $ (n + "Info ");
Fdo. className = "focus ";
Ido. innerHTML = ma [I];
}

Function showInfo (n, s ){
Var fdo = $ ("Tisi" + n );
VaR Ido = $ (n + "info ");
If (typeof S = 'undefined '){
Fdo. classname = "OK ";
Ido. innerhtml = "correct! ";
} Else {
Fdo. classname = "error ";
Ido. innerhtml = icon + S;
}
}

Function submits (){
CheckUsr ($ ("Tex" + ns [0]). value );
CheckPwd ($ ("Tex" + ns [1]). value );
CheckPwd2 ($ ("Tex" + ns [2]). value );
CheckEml ($ ("Tex" + ns [3]). value );
CheckCompany ($ ("Tex" + ns [4]). value );
CheckPhone ();
CheckFax ();
CheckDizi ($ ("Tex" + ns [7]). value );
CheckZip ($ ("Tex" + ns [8]). value );
CheckShengfen ();
CheckLinkname ($ ("Tex" + ns [9]). value );
CheckShouji ($ ("Tex" + ns [10]). value );
CheckUrl ($ ("Tex" + ns [11]). value );
CheckJieshao ($ ("Tex" + ns [12]). value );
CheckYanzheng ($ ("Tex" + ns [13]). value );

For (var I = 0; I <ns. length; I ++ ){
If ($ ("Tisi" + ns [I]). className = "error "){
$ ("Tex" + ns [I]). focus ();
Return false;
}
Else {
Continue;
}
}
// Return true;
Var fax = "", fw = "", mes = "failed to register due to network reasons. Contact the administrator. ";
Var baomi = 0;
Var tel = $ ("TexTelGJ"). value + "-" + $ ("TexTelQH"). value + "-" + $ ("TexTel"). value;

If (trim ($ ("TexFax"). value )! = ""){
Fax = $ ("TexFaxGJ"). value + "-" + $ ("TexFaxQH"). value + "-" + $ ("TexFax"). value;
}

For (var I = 1; I <7; I ++ ){
If ($ ("CheckBox" + I). Checked = "Checked "){
Fw + = $ ("CheckBox" + I). value + ",";
}
}

If ($ ("radiobuttonlist00000"). checked = "checked "){
Baomi = 0;
}
Else {
Baomi = 1;
}

Var a1 = $ ("TexLoginname"). value;
Var a2 = $ ("TexPassword"). value;
Var a3 = $ ("TexMail"). value;
Var a4 = $ ("TexCompanyname"). value;
Var a5 = $ ("TexDizhi"). value;
Var a6 = $ ("TexZip"). value;
Var a7 = $ ("DropShengfen"). value;
Var a8 = $ ("DropDiqu"). value;
Var a9 = $ ("TexLinkname"). value;
Var a10 = $ ("TexShouji"). value;
Var a11 = $ ("TexUrl"). value;
Var a12 = $ ("DropDownList3"). value;
VaR A13 = $ ("texjieshao"). value;

VaR Bret = join. addcompanya (A1, A2, A3, A4, tel, fax, A5, A6, A7, A8, A9, A10, baomi, A11, A12, FW, A13, $ ('hidip '). value ). value;

If (Bret = "1 "){
Location. href = "default. aspx ";
}
Else {
Alert (BRET );
}
// Call the background code to write it to the database
}
Function initPage (){
For (var I = 0; I <ns. length; I ++ ){
$ ("Tex" + ns [I]). value = "";
}
}

Note: See the following code application:<Asp: TextBox ID = "TexPassword" runat = "server" BorderStyle = "Groove" MaxLength = "16" onfocus = "inputfocus ('Password', 1) "onkeyup =" checkPwd (this. value); "onblur =" checkPwd (this. value );"
TextMode = "Password" Width = "150px"> </asp: TextBox>


<Asp: TextBox ID = "TexPassw" runat = "server" BorderStyle = "Groove" MaxLength = "16" onfocus = "inputfocus ('passw ', 2) "onkeyup =" checkPwd2 (this. value); "onblur =" checkPwd2 (this. value); "Width =" 150px "TextMode =" Password "> </asp: textBox> ...................................... ...................

Related Article

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.