/**
* 正则表达式对象;
* @type {{onlyNum: RegExp, passW: RegExp, chinaFont: RegExp, phoneNum: RegExp, cardNu: RegExp, emailExg: RegExp}}
*/
var regExp = {
onlyNum: /[0-9]+$/,
passW: /^[0-9a-zA-Z]{6,16}$/,
chinaFont: /^[a-zA-Z\u4E00-\u9FA5]{2,10}$/,
phoneNum:/^1[3|4|5|7|8][0-9]\d{4,8}$/,
cardNu:/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/,
emailExg: /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/
};
/**
* 进行验证和值的返回 函数体;
* @param v
* @param s
* @returns {*}
*/
var information = function(v,s){
var m = null;
switch (s){
case "pass":
m = regExp.passW;break;
case "onnu":
m = regExp.onlyNum;break;
case "cfon":
m = regExp.chinaFont;break;
case "phon":
m = regExp.phoneNum;break;
case "idca":
m = regExp.cardNu;break;
case "emal":
m = regExp.emailExg;break;
}
return (m.test(v))?(true):(false);
};
/************对验证的结果给予提示*************/
function TipFun(x){
var $this = this.nextElementSibling;
this.onfocus = function(){
$this.className = "";
$this.innerHTML = "";
};
if(x === true){
$this.innerHTML ="";
$this.className = "icon icon-ok-sign";
$this.style.color = "green";
}else{
$this.className = "";
$this.innerHTML = ‘<div style="position: absolute;left: 20px;top: 0; padding: 5px 5px;width: 100px;min-height: 30px;background-color: #fff;box-shadow: 0 0 5px #ccc;font-size: 14px;line-height: 1.4;color: #ccc;">您的输入存在不符合要求的字符,请您重新输入!</div>‘;
this.value = "";
}
}