87,984
社区成员
发帖
与我相关
我的任务
分享
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
function ajaxFunction()
{namex()
var xmlHttp;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
alert("您的浏览器不支持AJAX!");
return false;
}
}
}
xmlHttp.onreadystatechange=function()
{
var xx = document.getElementsByName("username")[0].value;
if (xx == ""){
document.getElementById("user_msg").innerHTML='<font color=red>不能为空!</font>';}
else if(document.getElementById('username').value.length < 6){
document.getElementById("user_msg").innerHTML='<font color=red>不能少于六!</font>';
}else if(xmlHttp.readyState==4)
{
var x = xmlHttp.responseText;//获取传过来的值
if(x == 1){
bb = "1";
document.getElementById("user_msg").innerHTML='<font color=green>√</font>';
}else{document.getElementById("user_msg").innerHTML='<font color=red>用户已经被注册</font>';}
}
}
var name=document.myForm.username.value;
xmlHttp.open("get","<?php echo site_url();?>/user/user_userx/?name="+name,true);//错误跟域名有关系192.168.1.102报错显示没权限 127.0.0.1没报错
xmlHttp.send(null);
}
</script>
</head>
<body>
<form name="myForm" action="/index.php/log/registration" method="post" onsubmit="return check();">
登陆账号:<input name="username" id="username" onblur="ajaxFunction(name);" onkeyup="value=value.replace(/[^\w\.\/]/ig,'')"
</form>
</body>
</html>