日期:2014-05-18  浏览次数:20740 次

最近无事 帮人做javascript , ajax 类的东西 免费
最近无事   帮人做javascript   ,   ajax   类的东西   免费

------解决方案--------------------
高手~~~~~~
------解决方案--------------------
注册的时候,当输完用户名,文本框失去焦点时,进后判断是否存在该用户,
如果存在,就在文本框的右边显示× 如果不存在却显示√
请问如何实现?要跟数据库打交道,用javascript 不可以吧?
如知道的给我代码,谢谢各位了!
------解决方案--------------------
用ajax就可以了
如:
<input type= "text " onblur= "checkForm( 'user ', 'userMsg ') " id= "user ">
<div id= "userMsg "> </div>

function checkForm(valueid,msgobj){
var http_request=false;
var valueobj=document.getElementById(valueid);
if(window.XMLHttpRequest){
http_request=new XMLHttpRequest();
if(http_request.overrideMimeType){
http_request.overrideMimeType( "text/html ");
}
}
else if(window.ActiveXObject){
try{
http_request=new ActiveXObject( "Xsxml2.XMLHTTP ");
}
catch(e){
try{
http_request=new ActiveXObject( "Microsoft.XMLHTTP ");
}
catch(e){
}
}
}
if(!http_request){
msgobj.innerHTML= " <font color=red> <b> 您的浏览器不支持XMLhttp,系统无法检测用户名的可用性! </b> </font> ";
return false;
}
http_request.onreadystatechange=function processRequest(){
if(http_request.readyState <4){msgobj.innerHTML= " <font color=green> <b> 系统正在检测,请稍等…… </b> </font> ";}
if(http_request.readyState==4){
if(http_request.status==200){
if(http_request.responseText==1){
msgobj.innerHTML= " <font color=green> <b> √该用户名可以注册. </b> </font> ";
document.reg.pass.readOnly=false;

}
else{
msgobj.innerHTML= " <font color=red> <b> ×该用户名已经被使用,请另外选择! </b> </font> ";}

}
else{
msgobj.innerHTML= " <font color=red> <b> ×页面出现异常,检测被中止,系统已经中止注册! </b> </font> ";
}
}
};
http_request.open( "GET ", "check.asp?username= "+valueobj.value,true);
http_request.send(null);
}
------解决方案--------------------
楼主啊。能不能给我一个ajax prototype最简单的例子啊?要能运行看的。网上的例子大多不全而且有点复杂了,sc-gameboy@163.com 谢谢
------解决方案--------------------
友情up