1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26-27--28 29---30 31--32 33 34 35 36 37 38-39 40 41 42 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 5, 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 11 9 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148-149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179-18 0 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196-197 |
JavaScript Document /* A common method for obtaining HTML objects by ID, using $ instead of function name/function $ (elementid) {return document.getElementById ( ElementID); /* When the mouse is placed in the Passport User name text box, the prompt text and style * * Function Usernamefocus () {var usernameid=$ ("Usernameid"); Usernameid.classname= " Import_prompt "; Usernameid.innerhtml= "1, composed of letters, numbers, underscores, dots, minus signs <br/>2, only with numbers, letters beginning or ending, and length of 4-18"; /* When the mouse leaves the Pass User name text box, prompt text and style */function Usernameblur () {var username=$ ("UserName"); var usernameid=$ ("Usernameid "); var reg=/^[0-9a-za-z][0-9a-za-z_.-]{2,16}[0-9a-za-z]$/; if (username.value== "") {usernameid.classname= "error_prompt"; usernameid.innerhtml= "the pass user name cannot be null, please enter the pass user name"; return False } if (Reg.test (username.value) ==false) {usernameid.classname= "error_prompt"; usernameid.innerhtml= "1, letters, numbers, underscores, dots, The minus sign is composed of <br/>2, only the number, the beginning or the end of the letter, and the length is 4-18 "; return false; } usernameid.classname= "Ok_prompt"; Usernameid.innerhtml= "Pass user name input correct"; return true; /* When the mouse is placed in the Password text box, the prompt text and style * * Function Pwdfocus () {var pwdid=$ ("Pwdid"); Pwdid.classname= "Import_prompt"; Pwdid.innerhtml= "Password length is 6-16"; * * When the mouse leaves the password text box, prompt text and style/function Pwdblur () {var pwd=$ ("pwd"); var pwdid=$ ("Pwdid"); if (pwd.value== "") { Pwdid.classname= "Error_prompt"; Pwdid.innerhtml= "Password cannot be blank, please enter password"; return false; } if (Pwd.value.length<6 | | pwd.value.length>16) {pwdid.classname= "error_prompt"; pwdid.innerhtml= "password length is 6-16"; return false; } pwdid.classname= "Ok_prompt"; pwdid.innerhtml= "Password input correct"; return true; /* When the mouse leaves the duplicate password text box, prompt text and style/function Repwdblur () {var repwd=$ ("Repwd"); var pwd=$ ("pwd"); var repwdid=$ ("Re Pwdid "); if (repwd.value== "") {repwdid.classname= "error_prompt"; repwdid.innerhtml= "duplicate password cannot be empty, repeat password"; return false;} if ( Repwd.value!=pwd.value) {repwdid.classname= "error_prompt"; repwdid.innerhtml= "two input passwords are inconsistent, please re-enter"; return false;} Repwdid.classname= "Ok_prompt"; Repwdid.innerhtml= "two times password input correct"; return true; /* When the mouse is placed in the nickname text box, the prompt text and style * * Function Nicknamefocus () {var nicknameid=$ ("Nicknameid"); Nicknameid.classname= " Import_prompt "; Nicknameid.innerhtml= "1, including Chinese characters, letters, numbers, underscores and @!#$%&* special characters <br/>2, length of 4-20 characters <br/>3, one Chinese characters for two characters "; /* When the mouse leaves the nickname text box, prompt text and style/function Nicknameblur () {var nickname=$ ("nickname"); var nicknameid=$ ("Nicknameid"); var k=0; var reg=/^ ([u4e00-u9fa5]|w|[ @!#$%&*]) +$/; Match nickname Var chinareg=/[u4e00-u9fa5]/g; Match Chinese character if (nickname.value== "") {nicknameid.classname= "error_prompt"; nicknameid.innerhtml= "nickname cannot be empty, please enter nickname"; return False } if (Reg.test (nickname.value) ==false) {nicknameid.classname= "error_prompt"; nicknameid.innerhtml= "only by Chinese characters, letters, numbers, Underline and @!#$%&* special characters "; return false; } var len=nickname.value.replace (Chinareg, "AB"). Length; Converts the Chinese characters to two letters to calculate the character length if (len<4| | LEN>20) {nicknameid.classname= "error_prompt"; nicknameid.innerhtml= "1, length is 4-20 characters <br/>2, one Chinese character occupies two characters"; return false; } Nicknameid.classname= "Ok_prompt"; Nicknameid.innerhtml= "nickname input correct"; return true; /* When the mouse is placed in the associated cell phone number text box, the prompt text and style * * Function Telfocus () {var telid=$ ("Telid"); Telid.classname= "Import_prompt"; Telid.innerhtml= "1, mobile phone number to 13,15,18 opening <br/>2, mobile phone number composed of 11 digits; /* When the mouse leaves the associated cell phone number text box, prompt text and style * * Function Telblur () {var tel=$ ("tel"); var telid=$ ("Telid"); var reg=/^ (13|15|18) d{9} $/; if (tel.value== "") {telid.classname= "error_prompt"; telid.innerhtml= "The associated mobile number cannot be empty, please enter the associated mobile number"; return false;} if ( Reg.test (Tel.value) ==false) {telid.classname= "error_prompt"; telid.innerhtml= "the associated cell phone number is entered incorrectly, please re-enter"; return false;} Telid.classname= "Ok_prompt"; Telid.innerhtml= "Related mobile phone number input correct"; return true; /* When the mouse is placed in the confidential mailbox text box, the prompt text and style */function Emailfocus () {var emailid=$ ("Emailid"); Emailid.classname= "Import_ Prompt "; Emailid.innerhtml= "Please input your commonly used e-mail"; /* When the mouse leaves the confidential mailbox text box, prompt text and style * * Function Emailblur () {var email=$ ("email"); var emailid=$ ("Emailid"); var reg=/^w+@w+ (. [A-za-z] {2,3}) {1,2}$/; if (email.value== "") {emailid.classname= "error_prompt"; emailid.innerhtml= "Confidential mailbox cannot be empty, please enter a confidential mailbox"; return false;} if ( Reg.test (Email.value) ==false) {emailid.classname= "error_prompt"; emailid.innerhtml= "the confidential mailbox is not in the correct format, please re-enter"; return false ; } EMailid.classname= "Ok_prompt"; Emailid.innerhtml= "Confidential mailbox input correct"; return true; /* Validation of form content input on form submission */function Checkform () {var flagusername=usernameblur (); var flagpwd=pwdblur (); var Flagrepwd=repwdblur (); var flagnickname=nicknameblur (); var flagtel=telblur (); var flagemail=emailblur (); Usernameblur (); Pwdblur (); Repwdblur (); Nicknameblur (); Telblur (); Emailblur (); if (flagusername==true &&flagpwd==true &&flagrepwd==true &&flagNickName==true& &flagtel==true&flagemail==true) {return true;} else{return false;} } |