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 43 44 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 84 85 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 119 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 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 |
<script language="JavaScript"> function isNumeric(strNumber) { return (strNumber.search(/^(-|/ + ) ? /d+(/. / d + ) ? $ / ) != -1); } // this function returns TRUE if a email address is right format function isEmail() { var email = (regfrm.email.value); // valid format "a@b.cd" invalidChars = " /;,:{}[]|*%$#!()`<>?"; if (email == "") { alert("请输入Email地址!"); regfrm.email.focus(); return false; } for (var i = 0; i < invalidChars.length; i++) { badChar = invalidChars.charAt(i); if (email.indexOf(badChar, 0) > -1) { alert("Email地址输入不正确!"); regfrm.email.focus(); return false; } } atPos = email.indexOf("@", 1) // there must be one "@" symbol if (atPos == -1) { alert("Email地址输入不正确!"); regfrm.email.focus(); return false; } if (email.indexOf("@", atPos + 1) != -1) { // and only one "@" symbol alert("Email地址输入不正确!"); regfrm.email.focus(); return false; } periodPos = email.indexOf(".", atPos); if (periodPos == -1) { // and at least one "." after the "@" alert("Email地址输入不正确!"); regfrm.email.focus(); return false; } // and at least one character between "@" and "." if (atPos + 2 > periodPos) { alert("Email地址输入不正确!"); regfrm.email.focus(); return false; } if (periodPos + 3 > email.length) { alert("Email地址输入不正确!"); regfrm.email.focus(); return false; } return true; } //function for check tel.no function istel(test) { var tel = test; var validchars = "-()1234567890 "; if (tel.length == 0) { alert("请输入电话号码!"); regfrm.phone.focus(); return false; } for (i = 0; i < tel.length; i++) { telchar = tel.charAt(i); if (validchars.indexOf(telchar, 0) == -1) { alert("电话号码输入不正确!"); regfrm.phone.focus(); return false; } } return true; } function isDate(day, month, year) { // let's first check the user entered numbers if (isNaN(Date.parse(month + "/" + day + "/" + year))) { return false; } var dd = parseInt(day, 10); // beware !! the computer handles monthes from 0 to 11. var mm = parseInt(month, 10) - 1; var yy = parseInt('20' + year, 10); var date = new Date(yy, mm, dd); //let's now compare the user's entry with what the computer understand of it if (dd != date.getDate() || mm != date.getMonth() || yy != date.getFullYear()) { return false; } return true; } function checkinput() { if (regfrm.checkbox.checked == false) { alert("您仔细阅读了《久游用户注册协议书》?"); return false; } if (regfrm.username.value.length == 0) { alert("请输入用户名"); regfrm.username.focus(); return false; } var r, re = new RegExp("[A-Za-z0-9]+", "g"); var s = regfrm.username.value; r = s.match(re); if (r == null || s.length != r[0].length) { alert("用户名只能为英数!"); regfrm.username.focus(); return false; } if (regfrm.username.value.length < 6) { alert("用户名必须大于6位"); regfrm.username.focus(); return false; } if (regfrm.username.value.length > 12) { alert("用户名不能超过12位"); regfrm.username.focus(); return false; } if (regfrm.nickname.value.length == 0) { alert("请输入昵称"); regfrm.nickname.focus(); return false; } if (regfrm.nickname.value.length > 16) { alert("昵称不能超过8个中文字符或者16个英文数字等组合"); regfrm.nickname.focus(); return false; } if (regfrm.password.value.length == 0) { alert("请输入密码"); regfrm.password.focus(); return false; } if (regfrm.password.value.length < 6) { alert("密码必须大于6位"); regfrm.password.focus(); return false; } if (regfrm.password.value.length > 20) { alert("密码不能超过20位"); regfrm.password.focus(); return false; } if (regfrm.password.value != regfrm.psw2.value) { alert("您两次输入的密码不一致"); regfrm.password.focus(); return false; } if (regfrm.secureCode.value.length == 0) { alert("请输入安全码"); regfrm.secureCode.focus(); return false; } if (regfrm.secureCode.value.length < 6) { alert("安全码必须大于6位"); regfrm.secureCode.focus(); return false; } if (regfrm.secureCode.value.length > 12) { alert("安全码不能超过12位"); regfrm.secureCode.focus(); return false; } if (regfrm.secureCode.value != regfrm.SerCode2.value) { alert("您两次输入的安全码不一致"); regfrm.secureCode.focus(); return false; } if (regfrm.idcard.value.length == 0) { alert("请输入身份证号码"); regfrm.idcard.focus(); return false; } var tempidcard = regfrm.idcard.value; if (regfrm.cardtype[1].checked == true) { if (regfrm.idcard.value.length != 18) { alert("身份证号码位数不对!"); regfrm.idcard.focus(); return false; } idcardlast = tempidcard.substring(17, 18); idcardfor = tempidcard.substring(0, 17); if (!isNumeric(idcardfor)) { alert("身份证号前17位必须是数字!"); regfrm.idcard.focus(); return false; } if (!isNumeric(idcardlast) && idcardlast != "x" && idcardlast != "X") { alert("身份证号最后一位必须是数字或者X!"); regfrm.idcard.focus(); return false; } } if (regfrm.cardtype[0].checked == true) { if (regfrm.idcard.value.length != 15) { alert("身份证号码位数不对!"); regfrm.idcard.focus(); return false; } idcardlast = tempidcard.substring(14, 15); idcardfor = tempidcard.substring(0, 14); if (!isNumeric(idcardfor)) { alert("身份证号前14位必须是数字!"); regfrm.idcard.focus(); return false; } if (!isNumeric(idcardlast) && idcardlast != "x" && idcardlast != "X") { alert("身份证号最后一位必须是数字或者X!"); regfrm.idcard.focus(); return false; } } if (isEmail() == false) { return false; } if (regfrm.realname.value.length == 0) { alert("请输入您的真实姓名"); regfrm.realname.focus(); return false; } if (regfrm.year.value.length == 0 || regfrm.year.value.length != 4) { alert("生日的年份必须为4位"); regfrm.year.focus(); return false; } if (isDate(regfrm.day.value, regfrm.month.value, regfrm.year.value) == false) { alert("您的生日输入有误"); regfrm.year.focus(); return false; } return true; } </script> |