<script>
var xmlHTTP=null;
var lastusername='';
function checkreturn(){
return (event.keyCode==13)?1:0;
}
function reg_check(){
if(document.getElementById('name').value.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == -1)
{ alert('用户名格式输入错误!'); document.getElementById('name').focus();return;}
if(document.getElementById('password').value.length<6){
alert('您的密码长度小于6位,请重新输入!');document.getElementById('password').focus();return;
}
if(document.getElementById('password').value.length>20){
alert('您的密码长度大于20位,请重新输入!');document.getElementById('password').focus();return;
}
if(document.getElementById('name').value.length>32){
alert('您的用户名长度大于32位,请重新输入!');document.getElementById('name').focus();return;
}
if(document.getElementById('password').value!=document.getElementById('password1').value){
alert('您的填写的用户名密码与确认密码不一致,请重新输入!');document.getElementById('password').focus();return;
}if(document.getElementById('email').value == "")
{ alert('E-mail地址不能为空!'); document.getElementById('email').focus();return;}
if(document.getElementById('email').value.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == -1)
{ alert('E-mail地址格式输入错误!'); document.getElementById('email').focus();return;}
document.forms['form1'].submit();
}
function clockon()
{
var now = new Date();
var year = now.getFullYear(); //getFullYear getYear
var month = now.getMonth();
var date = now.getDate();
var day = now.getDay();
var hour = now.getHours();
var minu = now.getMinutes();
var sec = now.getSeconds();
var week;
month = month+1;
if(month<10)month="0"+month;
if(date<10)date="0"+date;
if(hour<10)hour="0"+hour;
if(minu<10)minu="0"+minu;
if(sec<10)sec="0"+sec;
var arr_week = new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六");
week = arr_week[day];
var time = "";
time = year+"年"+month+"月"+date+"日"+" "+hour+":"+minu+":"+sec+" "+week;
document.getElementById("bgclock").innerHTML="["+time+"]";
var timer = setTimeout("clockon()",200);
}
function check_upper(){
var letter = document.getElementById('name').value;
if(letter.match("[A-Z]+"))
{
document.getElementById("checkname").innerHTML='<font color=red>用户名不能含大写英文字母!</font>';
}else{
document.getElementById("checkname").innerHTML='';
}
if(letter.match(/[\u4e00-\u9fa5]/g)){
document.getElementById("checkname").innerHTML='<font color=red>用户名不能含中文!</font>';
}
}
function _checkname()
{
if(xmlHTTP.readyState!=4)
return;
if(xmlHTTP.responseText == "ok"){
document.getElementById("checkname").innerHTML='<font color=green>该用户名可以使用!</font>';
}
else{
document.getElementById("checkname").innerHTML='<font color=red>该用户名已经存在,不可以使用!</font>';
}
}
function checkname(obj){
if (lastusername == obj.value)
{
return;
}
else
{
lastusername = obj.value;
}
if(lastusername.replace(/\s/g,"") == "")
{
document.getElementById("checkname").innerHTML='<font color=red>请输入用户名</font>';
obj.focus();
return;
}
if(lastusername.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == -1)
{
document.getElementById("checkname").innerHTML='<font color=red>用户名格式输入错误!</font>';
obj.focus();
return;
}
if(xmlHTTP==null){
xmlHTTP=new ActiveXObject("MSXML2.XMLHTTP");
}
xmlHTTP.abort();
xmlHTTP.onreadystatechange=_checkname;
xmlHTTP.open("GET","reg.php?act=checkname&checkname=" + encodeURI(lastusername),true);
xmlHTTP.send();
}
</script>