複製代碼 代碼如下:<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>