一直用JQuery,JavaScript都有些忘记了,今天又拾起来了。。。
<script LANGUAGE=javascript RUNAT=Server>
function isEmail(strEmail) {
/**
*检测邮箱
**/
var tdEmailTip = document.getElementById("email_td");
var td_email_tip = document.getElementById("email_tip");
var textNode1 = document.createTextNode("请输入邮箱地址");
var td_email_tip = document.getElementById("email_tip");
var textNode2 = document.createTextNode("请输入正确的邮箱地址");
var img = document.createElement("img");
img.src="img/zc_dh.png";
img.id="img";
var op = document.createElement("p")
="email_tip";
if(document.getElementById("email_chk").value==""&&!document.getElementById("email_tip").hasChildNodes())
{
td_email_tip.appendChild(textNode1);
document.getElementById("email_chk").focus();
}
if(document.getElementById("email_chk").value!="")
{
if(document.getElementById("email_td").hasChildNodes())
{ tdEmailTip.removeChild(td_email_tip);}
if (strEmail.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
{
if(document.getElementById("email_td").hasChildNodes())
{tdEmailTip.removeChild(td_email_tip);}
op.appendChild(img);
tdEmailTip.appendChild(op);
}else{
if(document.getElementById("email_td").hasChildNodes())
{tdEmailTip.removeChild(td_email_tip);}
op.appendChild(textNode2);
tdEmailTip.appendChild(op);
}
}
}
/**
*检验昵称
**/
function isNikName(nickname){
var nick_td = document.getElementById("name_td");
var nick_p = document.getElementById("pName");
var nickname=document.createElement("p");
="pName";
var textname = document.createTextNode("请输入昵称");
if(document.getElementById("nikname").value=="")
{
if(!document.getElementById("name_td").hasChildNodes()){
nickname.appendChild(textname);
nick_td.appendChild(nickname);
}
}else{
if(document.getElementById("name_td").hasChildNodes()){
nick_td.removeChild(nick_p);
}
}
}
/**
*检验密码
**/
function PasswordStrength(passwordID,strengthID){
this.init(strengthID);
var _this = this;
document.getElementById(passwordID).onkeyup = function(){
_this.checkStrength(this.value);
}
};
PasswordStrength.prototype.init = function(strengthID){
var id = document.getElementById(strengthID);
var div = document.createElement('div');
var strong = document.createElement('strong');
this.oStrength = id.appendChild(div);
this.oStrengthTxt = id.parentNode.appendChild(strong);
};
PasswordStrength.prototype.checkStrength = function (val){
var aLvTxt = ['','低','中','高'];
var lv = 0;
if(val.match(/[a-z]/g)){lv++;}
if(val.match(/[0-9]/g)){lv++;}
if(val.match(/(.[^a-z0-9])/g)){lv++;}
if(val.length < 6){lv=0;}
if(lv > 3){lv=3;}
this.oStrength.className = 'strengthLv' + lv;
this.oStrengthTxt.innerHTML = aLvTxt[lv];
};
/**
*进行其他项输入
***/
function chk_pwd(pwd){
document.getElementById("pwd_strength").style.display="none";
}
/**
*密码强度框显示
**/
function pwd_display(){
document.getElementById("pwd_strength").style.display="block";
}
/**
*确认密码
**/
function chk_repwd(){
if(document.getElementById("pass").value=="")
{
//alert("s输入");
var pwd_tip = document.getElementById("re_pwdchk");
var tippwd = document.createElement("p");
= "pwd_re";
var pp = document.getElementById("pwd_re");
var textNode = document.createTextNode("请输入密码");
if(!document.getElementById("re_pwdchk").hasChildNodes())
{
tippwd.appendChild(textNode);
pwd_tip.appendChild(tippwd);
}
}
}
</script>
















