js会员注册判断 是否为空
时间 :
2022-10-02
编辑 :超级管理员
function _(id) { return document.getElementById(id); }
function ErrorsNumber(minute, num) {
var date = new Date();
var strErrors = "";
var strNewErrors = "";
var count = 0;
var arrLogin = new Array();
var date = new Date();
strErrors = GetCookie("LoginErrors");
if (strErrors == undefined) strErrors = "";
arrError = strErrors.split(",")
for (var i = 0; i < arrError.length; i++) {
if (arrError[i] > date.getTime() - minute * 60 * 1000)
strNewErrors = strNewErrors + "," + arrError[i];
}
setCookie("LoginErrors", strNewErrors, 12 * 60);
if (strNewErrors.split(",").length > num) {
popbox.error('您在' + minute + '分钟内的连续登录错误次数超过' + num + '次,暂时禁止登录!');
return false;
}
return true;
}
function checkSubmit() {
if (_("username").value == "") {
popbox.error("请输入用户名");
_("userName").focus();
_("userName").style.color = '#000';
return false;
}
if (_("password").value == "") {
popbox.error("请输入密码");
_("password").focus();
return false;
}
_("username").value = escape(_("username").value);
_("password").value = escape(_("password").value);
return true;
}
function TrimSpace(obj) {
if (obj.value != obj.value.replace(/ /g, ""))
obj.value = obj.value.replace(/ /g, "");
if (obj.value != obj.value.replace(/ /g, ""))
obj.value = obj.value.replace(/ /g, "");
}
function CtoH(obj) {
var str = obj.value;
var result = "";
for (var i = 0; i < str.length; i++) {
if (str.charCodeAt(i) == 12288) {
result += String.fromCharCode(str.charCodeAt(i) - 12256);
continue;
}
if (str.charCodeAt(i) > 65280 && str.charCodeAt(i) < 65375)
result += String.fromCharCode(str.charCodeAt(i) - 65248);
else
result += String.fromCharCode(str.charCodeAt(i));
}
result = result.replace(/——/g, "_");
result = result.replace(/\(/g, "(");
result = result.replace(/\)/g, ")");
if (obj.value != result)
obj.value = result;
}
function setCookie(key, strName, value) // 变更名,子键名 ,子键值
{
var cookies = ""
var dc = "; " + document.cookie + "; ";
var cooNum = dc.indexOf("; " + key + "=");
var cookInfo = dc.substring(cooNum + key.length + 3, dc.length);
cookInfos = (cookInfo.split(";"))[0].split("&");
for (var i = 0; i < cookInfos.length; i++) {
var endPlace = cookInfos[i].indexOf("=");
var strCoo = cookInfos[i].substring(0, endPlace);
if (strName == strCoo) {
cookies = cookies + strName + "=" + value;
if (i != cookInfos.length - 1)
cookies = cookies + "&";
}
else {
cookies = cookies + cookInfos[i];
if (i != cookInfos.length - 1)
cookies = cookies + "&";
}
}
document.cookie = key + "=" + cookies;
}
//读取cookies值
function GetCookie(key, strName) // 变更名,子键名
{
var cookies = "";
var dc = "; " + document.cookie + "; ";
var cooNum = dc.indexOf("; " + key + "=");
var cookInfo = dc.substring(cooNum + key.length + 3, dc.length);
cookInfos = (cookInfo.split(";"))[0].split("&");
for (var i = 0; i < cookInfos.length; i++) {
var endPlace = cookInfos[i].indexOf("=");
var strCoo = cookInfos[i].substring(0, endPlace);
if (strName == strCoo)
cookies = cookInfos[i].substring(cookInfos[i].indexOf("=") + 1);
}
return cookies;
}
