本文共 2174 字,大约阅读时间需要 7 分钟。
- $(function () {
- $("input[name='sub']").on("click", function () {
- if (!isEmail($("input[name='email']").val())) {
- $("span[name='email']").html("邮箱格式错误");
- return false;
- }
- else {
- $("span[name='email']").html("");
- }
- if (checkStrong($("input[name='password']").val()) < 3) {
- $("span[name='password']").html("密码太过简单");
- return false;
- }
- else {
- $("span[name='password']").html("");
- }
- if (!isQQ($.trim($("input[name='qq']").val()))) {
- $("span[name='qq']").html("请输入正确的QQ号码");
- return false;
- }
- else {
- $("span[name='qq']").html("");
- }
- if (!isPhone($.trim($("input[name='mnumber']").val()))) {
- $("span[name='mnumber']").html("请输入正确的手机号码");
- return false;
- }
- else {
- $("span[name='mnumber']").html("");
- }
- return true;
- });
- });
-
- function isQQ(aQQ) {
- var bValidate = RegExp(/^[1-9][0-9]{4,9}$/).test(aQQ);
- if (bValidate) {
- return true;
- }
- else
- return false;
- }
-
- function isPhone(aPhone) {
- var bValidate = RegExp(/^(0|86|17951)?(13[0-9]|15[012356789]|18[0-9]|14[57])[0-9]{8}$/).test(aPhone);
- if (bValidate) {
- return true;
- }
- else
- return false;
- }
-
- function isEmail(aEmail) {
- var bValidate = RegExp(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/).test(aEmail);
- if (bValidate) {
- return true;
- }
- else
- return false;
- }
-
- function isInteger(s) {
- var isInteger = RegExp(/^[0-9]+$/);
- return (isInteger.test(s));
- }
-
- function CharMode(iN) {
- if (iN >= 48 && iN <= 57)
- return 1;
- if (iN >= 65 && iN <= 90)
- return 2;
- if (iN >= 97 && iN <= 122)
- return 4;
- else
- return 8;
- }
-
- function bitTotal(num) {
- modes = 0;
- for (i = 0; i < 4; i++) {
- if (num & 1) modes++;
- num >>>= 1;
- }
- return modes;
- }
-
- function checkStrong(sPW) {
- if (sPW.length <= 4)
- return 0;
- Modes = 0;
- for (i = 0; i < sPW.length; i++) {
-
- Modes |= CharMode(sPW.charCodeAt(i));
- }
- return bitTotal(Modes);
转载于:https://www.cnblogs.com/cymbidium/p/5083014.html