这个脚本对你可能有帮助:
<script language="javascript">
function IsDigit(cCheck)
{
return (('0'<=cCheck) && (cCheck<='9'));
}
function IsAlpha(cCheck)
{
return ((('a'<=cCheck) && (cCheck<='z')) || (('A'<=cCheck) && (cCheck<='Z')))
}
function IsaNull(cCheck)
{
return(cCheck != " ")
}
function checkform()
{
id = document.sform1.id.value;
if (id == "")
{
alert("请输入注册名");
document.sform1.id.focus();
return false;
}
for (nIndex=0; nIndex<id.length; nIndex++)
{
cCheck = id.charAt(nIndex);
if (!(IsDigit(cCheck) || IsAlpha(cCheck) || cCheck=='-' || cCheck=='_' || cCheck=='.'))
{
alert("用户名只能使用字母、数字以及-、_和.,并且不能使用中文");
document.sform1.id.focus();
return false;
}
}
chineseid = document.sform1.chineseid.value;
if (chineseid == "")
{
alert("请输入中文昵称");
document.sform1.chineseid.focus();
return false;
}
password = document.sform1.password.value;
if (password == "")
{
alert("请输入登陆密码");
document.sform1.password.focus();
return false;
}
password1 = document.sform1.password1.value;
if (password>password1)
{
alert("重复密码与登陆密码不相同");
document.sform1.password.focus();
document.sform1.password1.focus();
return false;
}
if (password<password1)
{
alert("重复密码与登陆密码不相同");
document.sform1.password.focus();
document.sform1.password1.focus();
return false;
}
if (document.sform1.email.value == "")
{
alert("请输入您的E-MAIL地址");
document.sform1.email.focus();
return false;
}
email=document.sform1.email.value;
emailerr=0
for (i=0; i<email.length; i++)
{
if ((email.charAt(i) == "@") & (email.length > 5))
{
emailerr=emailerr+1
}
}
if (emailerr != 1)
{
alert("请输入正确的E-MAIL地址");
document.sform1.email.focus();
return false;
}
if (document.sform1.checkask.value=="")
{
alert("密码提示问题不能为空");
document.sform1.checkask.focus();
return false;
}
if (document.sform1.checkans.value=="")
{
alert("您的密码提示问题答案不能为空");
document.sform1.checkans.focus();
return false;
}
return true;
}
</script>
本文地址:http://com.8s8s.com/it/it7193.htm