求js验证用户名注册 需要验证用户名学号是否存在并且合法不能为空,密码是否合法长度大于6位, 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 是否存在用Ajax + php实现 ajax不懂!!!!用js好像太麻烦了!是不是要先把数据酷的值调出来看是否存在在if判断啊 验证是否存在需要用ajax去后台验证有验证的插件,比如Jquery有form、formvalidate等,都是支持异步的 jquery插件好了validation不错 <input type="text" name="username" class="inputtext" size="25" onkeyup="usernamecheck()"> var xmlHttp;function createAJAX(){ try{ xmlHttp = new XMLHttpRequest(); } catch(e){ try{ xmlHttp=new ActiveXObject("Msxml2.XMLHTTP") } catch(e){ try{ xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch(e){ alert("您的浏览器不支持AJAX!"); return; } } }}function usernamecheck(){ str=document.userinfo.username.value; var url="userquery.php?str="+str; if(str.length!=0){ createAJAX(); xmlHttp.onreadystatechange=query; xmlHttp.open("GET",url,true); xmlHttp.send(null); }else{ document.getElementById("checkusername").innerText=""; }}function query(){ if (xmlHttp.readyState == 4 ){ if (xmlHttp.status==200) { if (xmlHttp.responseText=="true"){ document.getElementById("checkusername").innerText="该帐号已被占用"; //document.getElementById("checkusername").innerText=xmlHttp.responseText; document.all.isadd.value="true"; }else { document.getElementById("checkusername").innerText="该帐号可用"; document.all.isadd.value="false"; } } }}$conn=mysql_connect('localhost','root','root');mysql_select_db('shop', $conn);$str=$_GET["str"];$sql="select * from userinfo where username='$str' ";$result=mysql_query($sql);if(mysql_num_rows($result)==0){ echo "false";}else{ echo "true";}一个验证用户的代码 长度等其它比较简单 自己写下 NetBeans如何用xdebug调试PHP ckfinder不能上传大文件 php共同交流 php什么书,或者教程比较好,我想学一把,麻烦高手推荐一下,谢谢! php 中的file_get_contents 问题 一个数组,怎么找到乘积小于某一个数的组合,并保留 请教视频转换 我在php中写了一个图片链接,可是为什么出来的效果却在图片四周多了蓝色边框呢?怎么去掉啊? 实在没办法了,大家救急,完不成就不能回家了include问题 请教大家一个关于投票数显示的问题 PHP生成的图片不继承父目录的权限 怎么把一个php类文件里面的代码全部读出来?
有验证的插件,比如Jquery有form、formvalidate等,都是支持异步的
validation不错
<input type="text" name="username" class="inputtext" size="25" onkeyup="usernamecheck()"> var xmlHttp;
function createAJAX(){
try{
xmlHttp = new XMLHttpRequest();
} catch(e){
try{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP")
} catch(e){
try{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
} catch(e){
alert("您的浏览器不支持AJAX!");
return;
}
}
}
}
function usernamecheck(){
str=document.userinfo.username.value;
var url="userquery.php?str="+str;
if(str.length!=0){
createAJAX();
xmlHttp.onreadystatechange=query;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}else{
document.getElementById("checkusername").innerText="";
}
}
function query(){
if (xmlHttp.readyState == 4 ){
if (xmlHttp.status==200)
{
if (xmlHttp.responseText=="true"){
document.getElementById("checkusername").innerText="该帐号已被占用";
//document.getElementById("checkusername").innerText=xmlHttp.responseText;
document.all.isadd.value="true";
}else {
document.getElementById("checkusername").innerText="该帐号可用";
document.all.isadd.value="false";
}
}
}
}$conn=mysql_connect('localhost','root','root');
mysql_select_db('shop', $conn);
$str=$_GET["str"];
$sql="select * from userinfo where username='$str' ";
$result=mysql_query($sql);
if(mysql_num_rows($result)==0){
echo "false";
}else{
echo "true";
}一个验证用户的代码 长度等其它比较简单 自己写下