东莞企业营销型网站策划,开发公司名字,wordpress 悬停遮罩,网红营销的优势在哪里最近用phpjsmysql做了一个仿webQQ的课程设计#xff0c;收获很多#xff0c;现在将关键的技术总结一下#xff0c;供大家学习交流。1邮箱验证用户在注册的时候#xff0c;会在文本框里输入邮箱#xff0c;这个时候通过文本框的onblur和onchange事件用Ajax无刷新技…最近用phpjsmysql做了一个仿webQQ的课程设计收获很多现在将关键的技术总结一下供大家学习交流。1邮箱验证用户在注册的时候会在文本框里输入邮箱这个时候通过文本框的onblur和onchange事件用Ajax无刷新技术来判断用户输入的邮箱是否合法以及是否与已注册的邮箱冲突。Js代码[html]function checkEmail(Email){var xmlhttp;if (window.XMLHttpRequest){// code for IE7, Firefox, Chrome, Opera, Safarixmlhttpnew XMLHttpRequest();if(xmlhttp.overrideMimeType){//设置MIME类别xmlhttp.overrideMimeType(text/xml);}}else{// code for IE6, IE5xmlhttpnew ActiveXObject(Microsoft.XMLHTTP);}var urlcheckEmail.php?emaildocument.getElementById(email).value; //转到checkEmail.php进行验证xmlhttp.open(GET,url,true);xmlhttp.onreadystatechangefunction(){if (xmlhttp.readyState4 xmlhttp.status200){document.getElementById(error1).innerHTMLxmlhttp.responseText;}}xmlhttp.send(null);}function checkEmail(Email){var xmlhttp;if (window.XMLHttpRequest){// code for IE7, Firefox, Chrome, Opera, Safarixmlhttpnew XMLHttpRequest();if(xmlhttp.overrideMimeType){//设置MIME类别xmlhttp.overrideMimeType(text/xml);}}else{// code for IE6, IE5xmlhttpnew ActiveXObject(Microsoft.XMLHTTP);}var urlcheckEmail.php?emaildocument.getElementById(email).value; //转到checkEmail.php进行验证xmlhttp.open(GET,url,true);xmlhttp.onreadystatechangefunction(){if (xmlhttp.readyState4 xmlhttp.status200){document.getElementById(error1).innerHTMLxmlhttp.responseText;}}xmlhttp.send(null);}PHP代码[php]*邮箱不能为空;}else{if($len50){echo *邮箱不要超过50个字符;}else{if(eregi(^[_.0-9a-z-]([0-9a-z][0-9a-z-].)[a-z]{2,3}$,$email)) //在php中用正则表达式验证邮箱{$sqlselect * from user where email$email; //连接数据库进行查询看邮箱是否被用$result mysql_query($sql);$nummysql_num_rows($result);if($num0){echo *该邮箱已被用;}else{echo *邮箱可用;}}else{echo *该邮箱不可用;}}}?*邮箱不能为空;}else{if($len50){echo *邮箱不要超过50个字符;}else{if(eregi(^[_.0-9a-z-]([0-9a-z][0-9a-z-].)[a-z]{2,3}$,$email)) //在php中用正则表达式验证邮箱{$sqlselect * from user where email$email; //连接数据库进行查询看邮箱是否被用$result mysql_query($sql);$nummysql_num_rows($result);if($num0){echo *该邮箱已被用;}else{echo *邮箱可用;}}else{echo *该邮箱不可用;}}}?通过对邮箱验证的学习我想其他的验证应该很简单了吧(未完待续)摘自 wyzhangchengjin123