ajax+php 无刷新文件上传代码

 更新时间:2016年11月25日 16:28  点击:1484
在php文件上传这一款,如果不用ajax来实现,效果都不怎么样,用户体验不怎么好,下面我们就来看看这一款ajax+php 无刷新文件上传代码吧。ajax+php 无刷新文件上传代码

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.111cn.net/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<title>ajax+php 无刷新文件上传代码</title>
</head>
<body>
<style>
.fu_list {
 width:600px;
 background:#ebebeb;
 font-size:12px;
}
.fu_list td {
 padding:5px;
 line-height:20px;
 background-color:#fff;
}
.fu_list table {
 width:100%;
 border:1px solid #ebebeb;
}
.fu_list thead td {
 background-color:#f4f4f4;
}
.fu_list b {
 font-size:14px;
}
/*file容器样式*/
a.files {
 width:90px;
 height:30px;
 overflow:hidden;
 display:block;
 border:1px solid #bebebe;
 background:url(img/fu_btn.gif) left top no-repeat;
 text-decoration:none;
}
a.files:hover {
 background-color:#ffffee;
 background-position:0 -30px;
}
/*file设为透明,并覆盖整个触发面*/
a.files input {
 margin-left:-350px;
 font-size:30px;
 cursor:pointer;
 filter:alpha(opacity=0);
 opacity:0;
}
/*取消点击时的虚线框*/
a.files, a.files input {
 outline:none;/*ff*/
 hide-focus:expression(this.hidefocus=true);/*ie*/
}
</style>
<form id="uploadform" action="file.php">
  <table border="0" cellspacing="1" class="fu_list">
    <thead>
      <tr>
        <td colspan="2"><b>上传文件</b></td>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td align="right" width="15%" style="line-height:35px;">添加文件:</td>
        <td><a href="网页特效:void(0);" class="files" id="idfile"></a> <img id="idprocess" style="display:none;" src="img/loading.gif" /></td>
      </tr>
      <tr>
        <td colspan="2"><table border="0" cellspacing="0">
            <thead>
              <tr>
                <td>文件路径</td>
                <td width="100"></td>
              </tr>
            </thead>
            <tbody id="idfilelist">
            </tbody>
          </table></td>
      </tr>
      <tr>
        <td colspan="2" style="color:gray">温馨提示:最多可同时上传 <b id="idlimit"></b> 个文件,只允许上传 <b id="idext"></b> 文件。 </td>
      </tr>
      <tr>
        <td colspan="2" align="center" id="idmsg"><input type="button" value="开始上传" id="idbtnupload" disabled="disabled" />
          &nbsp;&nbsp;&nbsp;
          <input type="button" value="全部取消" id="idbtndel" disabled="disabled" />
        </td>
      </tr>
    </tbody>
  </table>
</form>
<script type="text/网页特效">

var isie = (document.all) ? true : false;

var $ = function (id) {
    return "string" == typeof id ? document.getelementbyid(id) : id;
};

var class = {
  create: function() {
    return function() {
      this.initialize.apply(this, arguments);
    }
  }
}

var extend = function(destination, source) {
 for (var property in source) {
  destination[property] = source[property];
 }
}

var bind = function(object, fun) {
 return function() {
  return fun.apply(object, arguments);
 }
}

var each = function(list, fun){
 for (var i = 0, len = list.length; i < len; i++) { fun(list[i], i); }
};

//文件上传类
var fileupload = class.create();
fileupload.prototype = {
  //表单对象,文件控件存放空间
  initialize: function(form, folder, options) {
 
 this.form = $(form);//表单
 this.folder = $(folder);//文件控件存放空间
 this.files = [];//文件集合
 
 this.setoptions(options);
 
 this.filename = this.options.filename;
 this._framename = this.options.framename;
 this.limit = this.options.limit;
 this.distinct = !!this.options.distinct;
 this.extin = this.options.extin;
 this.extout = this.options.extout;
 
 this.oninifile = this.options.oninifile;
 this.onempty = this.options.onempty;
 this.onnotextin = this.options.onnotextin;
 this.onextout = this.options.onextout;
 this.onlimite = this.options.onlimite;
 this.onsame = this.options.onsame;
 this.onfail = this.options.onfail;
 this.onini = this.options.onini;
 
 if(!this._framename){
  //为每个实例创建不同的iframe
  this._framename = "uploadframe_" + math.floor(math.random() * 1000);
  //ie不能修改iframe的name
  var oframe = isie ? document.createelement("<iframe name="" + this._framename + "">") : document.createelement("iframe");
  //为ff设置name
  oframe.name = this._framename;
  oframe.style.display = "none";
  //在ie文档未加载完用appendchild会报错
  document.body.insertbefore(oframe, document.body.childnodes[0]);
 }
 
 //设置form属性,关键是target要指向iframe
 this.form.target = this._framename;
 this.form.method = "post";
 //注意ie的form没有enctype属性,要用encoding
 this.form.encoding = "multipart/form-data";

 //整理一次
 this.ini();
  },
  //设置默认属性
  setoptions: function(options) {
    this.options = {//默认值
  filename: "files[]",//文件上传控件的name,配合后台使用
  framename: "",//iframe的name,要自定义iframe的话这里设置name
  oninifile: function(){},//整理文件时执行(其中参数是file对象)
  onempty: function(){},//文件空值时执行
  limit:  10,//文件数限制,0为不限制
  onlimite: function(){},//超过文件数限制时执行
  distinct: true,//是否不允许相同文件
  onsame:  function(){},//有相同文件时执行
  extin:  ["gif","jpg","rar","zip","iso","swf","exe"],//允许后缀名
  onnotextin: function(){},//不是允许后缀名时执行
  extout:  [],//禁止后缀名,当设置了extin则extout无效
  onextout: function(){},//是禁止后缀名时执行
  onfail:  function(){},//文件不通过检测时执行(其中参数是file对象)
  onini:  function(){}//重置时执行
    };
    extend(this.options, options || {});
  },
  //整理空间
  ini: function() {
 //整理文件集合
 this.files = [];
 //整理文件空间,把有值的file放入文件集合
 each(this.folder.getelementsbytagname("input"), bind(this, function(o){
  if(o.type == "file"){ o.value && this.files.push(o); this.oninifile(o); }
 }))
 //插入一个新的file
 var file = document.createelement("input");
 file.name = this.filename; file.type = "file"; file.onchange = bind(this, function(){ this.check(file); this.ini(); });
 this.folder.appendchild(file);
 //执行附加程序
 this.onini();
  },
  //检测file对象
  check: function(file) {
 //检测变量
 var bcheck = true;
 //空值、文件数限制、后缀名、相同文件检测
 if(!file.value){
  bcheck = false; this.onempty();
 } else if(this.limit && this.files.length >= this.limit){
  bcheck = false; this.onlimite();
 } else if(!!this.extin.length && !regexp(".(" + this.extin.join("|") + ")$", "i").test(file.value)){
  //检测是否允许后缀名
  bcheck = false; this.onnotextin();
 } else if(!!this.extout.length && regexp(".(" + this.extout.join("|") + ")$", "i").test(file.value)) {
  //检测是否禁止后缀名
  bcheck = false; this.onextout();
 } else if(!!this.distinct) {
  each(this.files, function(o){ if(o.value == file.value){ bcheck = false; } })
  if(!bcheck){ this.onsame(); }
 }
 //没有通过检测
 !bcheck && this.onfail(file);
  },
  //删除指定file
  delete: function(file) {
 //移除指定file
 this.folder.removechild(file); this.ini();
  },
  //删除全部file
  clear: function() {
 //清空文件空间
 each(this.files, bind(this, function(o){ this.folder.removechild(o); })); this.ini();
  }
}

var fu = new fileupload("uploadform", "idfile", { extin: ["gif","jpg"],
 oninifile: function(file){ file.value ? file.style.display = "none" : this.folder.removechild(file); },
 onempty: function(){ alert("请选择一个文件"); },
 onlimite: function(){ alert("超过上传限制"); },
 onsame: function(){ alert("已经有相同文件"); },
 onnotextin: function(){ alert("只允许上传" + this.extin.join(",") + "文件"); },
 onfail: function(file){ this.folder.removechild(file); },
 onini: function(){
  //显示文件列表
  var arrrows = [];
  if(this.files.length){
   var othis = this;
   each(this.files, function(o){
    var a = document.createelement("a"); a.innerhtml = "取消"; a.href = "javascript:void(0);";
    a.onclick = function(){ othis.delete(o); return false; };
    arrrows.push([o.value, a]);
   });
  } else { arrrows.push(["<font color='gray'>没有添加文件</font>", "&nbsp;"]); }
  addlist(arrrows);
  //设置按钮
  $("idbtnupload").disabled = $("idbtndel").disabled = this.files.length <= 0;
 }
});

$("idbtnupload").onclick = function(){
 //显示文件列表
 var arrrows = [];
 each(fu.files, function(o){ arrrows.push([o.value, "&nbsp;"]); });
 addlist(arrrows);
 
 fu.folder.style.display = "none";
 $("idprocess").style.display = "";
 $("idmsg").innerhtml = "正在添加文件到您的网盘中,请稍候……<br />有可能因为网络问题,出现程序长时间无响应,请点击"<a href='?'><font color='red'>取消</font></a>"重新上传文件";
 
 fu.form.submit();
}

//用来添加文件列表的函数
function addlist(rows){
 //根据数组来添加列表
 var filelist = $("idfilelist"), ofragment = document.createdocumentfragment();
 //用文档碎片保存列表
 each(rows, function(cells){
  var row = document.createelement("tr");
  each(cells, function(o){
   var cell = document.createelement("td");
   if(typeof o == "string"){ cell.innerhtml = o; }else{ cell.appendchild(o); }
   row.appendchild(cell);
  });
  ofragment.appendchild(row);
 })
 //ie的table不支持innerhtml所以这样清空table
 while(filelist.haschildnodes()){ filelist.removechild(filelist.firstchild); }
 filelist.appendchild(ofragment);
}


$("idlimit").innerhtml = fu.limit;

$("idext").innerhtml = fu.extin.join(",");

$("idbtndel").onclick = function(){ fu.clear(); }

//在后台通过window.parent来访问主页面的函数
function finish(msg){ alert(msg); location.href = location.href; }

</script>
</body>
</html>

file.php文件

<?
$sort=12;
$f_type=strtolower("swf,jpg,rar,zip,7z,iso,gif");//设置可上传的文件类型
$file_size_max=200*1024*1024;//限制单个文件上传最大容量
$overwrite = 0;//是否允许覆盖相同文件,1:允许,0:不允许
$f_input="files";//设置上传域名称
    foreach($_files[$f_input]["error"] as $key => $error){
        $up_error="no";
        if ($error == upload_err_ok){
            $f_name=$_files[$f_input]['name'][$key];//获取上传源文件名
   $uploaddir ='./www.111cn.net/';
            $uploadfile=$uploaddir.strtolower(basename($f_name));
            
            $tmp_type=substr(strrchr($f_name,"."),1);//获取文件扩展名
   $tmp_type=strtolower($tmp_type);
            if(!stristr($f_type,$tmp_type)){
                echo "<script>alert('对不起,不能上传".$tmp_type."格式文件, ".$f_name." 文件上传失败!')</script>";
                $up_error="yes";
            }
            
            if ($_files[$f_input]['size'][$key]>$file_size_max) {
   
                echo "<script>alert('对不起,你上传的文件 ".$f_name." 容量为".round($_files[$f_input]
['size'][$key]/1024)."kb,大于规定的".($file_size_max/1024)."kb,上传失败!')</script>";
                $up_error="yes";
            }
            
            if (file_exists($uploadfile)&&!$overwrite){
                echo "<script>alert('对不起,文件 ".$f_name." 已经存在,上传失败!')</script>";
                $up_error="yes";
            }
             $string = 'abcdefghijklmnopgrstuvwxyz0123456789';
$rand = '';
for ($x=0;$x<12;$x++)
  $rand .= substr($string,mt_rand(0,strlen($string)-1),1);
$t=date("ymdhis").substr($gettime[0],2,6).$rand;
$attdir="./file/"; 
    if(!is_dir($attdir))  
    {  mkdir($attdir);}
            $uploadfile=$attdir.$t.".".$tmp_type;
            if(($up_error!="yes") and (move_uploaded_file($_files[$f_input]['tmp_name']

[$key], $uploadfile))){

                
    $_msg=$_msg.$f_name.'上传成功 ';
    
    
            }
   else{
   $_msg=$_msg.$f_name.'上传失败 ';
   }
        }
 
    }
echo "<script>window.parent.finish('".$_msg."');</script>"; 
?>

这个文件上传类可以实现多个文件或单个文件进行上传了,下面小编来给各位推荐一个不错的例子。

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.111cn.net/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>

<body>
<?php
//php文件上传类(该类支持单个或者多个文件上传)
 /**
 * 类名:upfile
 * 作用:处理文件上传
 * 说明,该类处理单个或者多个文件上传,使用该类时,只需要实列化该类
 * 例:
 * $up = upfile()
 * $up->update_file($_file['filename'])
 *
 * $up->update_file   函数返回一个数组,如果是多文件上传,则为多维数据。
 * 数组的内容:
 * $fileinfo['file_size']   上传文件的大小
 * $fileinfo['file_suffix'] 上传文件的类型
 * $fileinfo['file_name']   上传文件的名字
 * $fileinfo['error']     上传文件产生的错误
 *

 */
class upfile {
 public $fcount = 1;           //上传文件的数量
 public $ftype  = array('jpg','jpeg','gif','png');  //文件格式
 public $fsize  = 1024;          //文件大小单位kb
 public $fdir   = 'www.111cn.net/';         //文件存放目录
 public $errormsg = '';          //产生的临时错误信息

 /**
  *函数名:get_tmp_file($putfile)
  *作用:取得上传的临时文件名
  *@param array $putfile
  *@return string $upimg 返回临时文件名
  */
  function get_tmp_file($putfile){
  if($this->fcount == 1){
   $tmpfile = $putfile['tmp_name'];
  }else{
   for($i=0;$i<$this->fcount;$i++){
    $tmpfile[] = $putfile['tmp_name'][$i];
   }
  }
  return $tmpfile;
  }

 代码如下 复制代码
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.111cn.net/1999/xhtml">
<head>
<meta content="text/html; charset=utf-8" http-equiv="content-type" />
<title></title>
<script language="网页特效" type="text/网页特效">
function addinput()//增加input节点
{
var input=document.createelement('input');//创建一个input节点
var br=document.createelement('br');//创建一个br节点
input.setattribute('type','file');// 设置input节点type属性为file
input.setattribute('name','files[]');//设置input节点 name属性为files[],以 数组的方式传递给服务器端
document.form1.appendchild(br);//把节点添加到 form1表单中
document.form1.appendchild(input);
}
</script>
</head>
<?php
if($_post['sub']=="www")
{
$waterimg="water.png";
$ftype=array('image/jpg','image/jpeg','imgage/png','image/pjpeg','image/gif');//允许上传的文件类型
$files=$_files['files'];
$fnum=count($files['name']); //取得上传文件个数
for($i=0;$i<$fnum;$i++)
{
 
   if($files['name'][$i]!=''&&is_uploaded_file($files['tmp_name'][$i]))
   {
  
    if(in_array($files['type'][$i],$ftype))//判断文件是否是允许的类型
    {
 
     $fname[$i]='upfile/'.rand(0,10000).time().substr($files['name'] [$i],strrpos($files['name'][$i],'.'));//自动命名
     move_uploaded_file($files['tmp_name'][$i],$fname[$i]);
     echo '<br/>文件上传成功!';
 
    }
    else
    {
     echo '<br/>不允许的文件类型!';
  exit;
    }
   }
   else
   {
    echo '<br/>该文件不存在!';
 exit;
   }
watermark($fname[$i],$waterimg);   
}
 
  $string=implode('|',$fname);
 echo $string;
}
 
?>
<body>
<form name="form1" method="post" action="" enctype="multipart/form-data" >
    <input type="file" name="files[]" id="files[]" />
<input type="submit" name="sub" value="上传"/>
<input name="sub" type="hidden" id="sub" value="www" />
</form>
<a href="#" onclick="addinput()">再上传一张</a>
<?
/**
* 为图片加水印
* @param string $desimg 目标图片 参数格式为 ./images/pic.jpg
* @param string $waterimg 水印图片 参数格式同上,水印图片为 png格式,背景透明
* @param int positon 水印地位 1:顶部居左 2:顶部居右 3:居中 4 :底部居左 5:底部居右
* @param bool $saveas 能否另存为,默许值false,默示笼盖原图
* @param int $alpha 水印图片的不通明度
* @return string $savepath 新图片的途径
* **/
function watermark($desimg,$waterimg,$positon=1,$saveas=false,$alpha=30)
{
//获取目图片的根基信息
$temp=pathinfo($desimg);
$name=$temp["basename"];//文件名
$path=$temp["dirname"];//文件地点的文件夹
$extension=$temp["extension"];//文件扩展名
if($saveas)
{
//需要另存为
$name=rtrim($name,".$extension")."_2.";//从头命名
$savepath=$path."/".$name.$extension;
}
else
{
//不需要另存为则笼盖原图
$savepath=$path."/".$name;
}
$info=getimageinfo($desimg);//获取目标图片的信息
$info2=getimageinfo($waterimg);//获取水印图片的信息
$desimg=create($desimg);//从原图创立
$waterimg=create($waterimg);//从水印图片创立
//地位1:顶部居左
if($positon==1)
{
$x=0;
$y=0;
}
//地位2:顶部居右
if($positon==2)
{
$x=$info[0]-$info2[0];
$y=0;
}
//地位3:居中
if($positon==3)
{
$x=($info[0]-$info2[0])/2;
$y=($info[1]-$info2[1])/2;
}
//地位4:底部居左
if($positon==4)
{
$x=0;
$y=$info[1]-$info2[1];
}
//地位5:底部居右
if($positon==5)
{
$x=$info[0]-$info2[0];
$y=$info[1]-$info2[1];
}
imagecopymerge($desimg,$waterimg,$x,$y,0,0,$info2[0],$info2[1],$alpha);
imagejpeg($desimg,$savepath);
imagedestroy($desimg);
imagedestroy($waterimg);
return $savepath;
}
/**
* 获取图片的信息,width,height,image/type
* @param string $src 图片途径
* @return 数组
* **/
function getimageinfo($src)
{
return getimagesize($src);
}
/**
* 创立图片,前往本钱范例
* @param string $src 图片途径
* @return resource $im 前往本钱范例
* **/
function create($src)
{
$info=getimageinfo($src);
switch ($info[2])
{
case 1:
$im=imagecreatefromgif($src);
break;
case 2:
$im=imagecreatefromjpeg($src);
break;
case 3:
$im=imagecreatefrompng($src);
break;
}
return $im;
}
 ?>

</body>
</html>

csv是常用的excel格式的替代品哦,很多时候我们导出数据是都会导成csv格式的,这样和excel没什么区别,下面的程序是要读取csv数据保存到数组我们要对数据进行操作,所以保存到数据。
 代码如下 复制代码

$info=csvtoarray::open('teste.csv');
//echo '<pre>';
//print_r($info);
//echo '</pre>';
foreach ($info as $c)
 {
  echo '学号:'.$c[0];
  echo '姓名:'.$c[1];
  echo '年龄:'.$c[2];
  echo '身高:'.$c[3].'<br>';
 }
 

 final class csvtoarray{

  /**
   * 把csv文件解析为一个数组返回
   *
   * @param string $file 要解析的csv文件路径
   * @param char $delimiter csv文件里的内容分隔符 默认为;
   * @return array
   */
  public static function open($file, $delimiter = ';'){
   return self::ordenamultiarray(self::csvarray($file, $delimiter), 1);
  }

  private function csvarray($file, $delimiter)
  {
   $result = array();
   $size = filesize($file) + 1;
   $file = fopen($file, 'r');
   $keys = fgetcsv($file, $size, $delimiter);
   fseek($file,0);//这里原来的没有..自己加上..这样能读取到第一行的内容
   while ($row = fgetcsv($file, $size, $delimiter))
   {
    for($i = 0; $i < count($row); $i++)
    {
     if(array_key_exists($i, $keys))
     {
      $row[$keys[$i]] = $row[$i];
     }
    }
    print_r($row);
    $result[] = $row;
   }

   fclose($file);

   return $result;
  }
  private function ordenamultiarray($multiarray, $secondindex)
  {
   while (list($firstindex, ) = each($multiarray))
   $indexmap[$firstindex] = $multiarray[$firstindex][$secondindex];
   asort($indexmap);
   while (list($firstindex, ) = each($indexmap))
   if (is_numeric($firstindex))
   $sortedarray[] = $multiarray[$firstindex];
   else $sortedarray[$firstindex] = $multiarray[$firstindex];
   return $sortedarray;
  }
 }

会员注册验证代码(php+mysql+Ajax)

会员注册验证代码(php教程+mysql教程+ajax)
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link href="images/css教程.css" rel="stylesheet" type="text/css" />
<title>会员注册验证代码(php+mysql+ajax)</title>
<script language="网页特效" src="网页特效/common.网页特效"></script>
<script language="网页特效" src="js/prototype.js"></script>
<script language="javascript" src="js/passwordstrength.js"></script>
<script language="javascript">
 var icon = '';
 var ns = ["usr","pwd","repwd","eml"];
 function changeusr(){
  if($("checkbtn").disabled) $("checkbtn").disabled = false;  
 }
 function checkusr(s){  
  var ma = ["用户名(4-16位)!","用户名由数字、英文、下划线、中杠线组成!"];
  if(!limitlen(s,4,16)){
   showinfo("usr",ma[0]);
   return false;
  }
  if(!hasaccountchar(s)){
   showinfo("usr",ma[1]);
   return false;
  }
  showinfo("usr");
  return true;
 }
 function checkpwd(s){
  var ma = ["密码(6-16位)!","密码不能包含中文或全角符号!","两次输入的密码不一致!"];
  ps教程.update(s);
  if(!limitlen(s,6,16)){
   showinfo("pwd",ma[0]);
   return false;
  }
  if(haschinesechar(s)){
   showinfo("pwd",ma[1]);
   return false;
  }
  if(limitlen($f("repwdinput"),6,16)){
   if(trim($f("repwdinput")) == trim(s)){
    showinfo("pwd");
    showinfo("repwd");
    return true;
   }else{
    showinfo("pwd",ma[2]);
    return false;
   }
  }
  showinfo("pwd");
  return true;
 }
 function checkpwd2(s){
  var ma = ["确认密码(6-16位)!","密码不能包含中文或全角符号!","两次输入的密码不一致!"];
  if(!limitlen(s,6,16)){
   showinfo("repwd",ma[0]);
   return false;
  }
  if(haschinesechar(s)){
   showinfo("repwd",ma[1]);
   return false;
  }
  if(limitlen($f("pwdinput"),6,16)){
   if(trim($f("pwdinput")) == trim(s)){
    showinfo("pwd");
    showinfo("repwd");
    return true;
   }else{
    showinfo("repwd",ma[2]);
    return false;
   }
  }
  showinfo("repwd");
  return true;
 }
 function checkeml(s){
  var ma = ["请输入常用邮件!","邮件格式不正确!"];
  if(s.length < 5){
   showinfo("eml",ma[0]);
   return false;
  }
  if(!isemail(s)){
   showinfo("eml",ma[1]);
   return false;
  }
  showinfo("eml");
  return true;
 }
 function showinfo(n,s){
  var fdo = $(n+"framediv");
  var ido = $(n+"infodiv");
  if(typeof s == 'undefined'){
   fdo.classname = "framedivpass";
   ido.innerhtml = "<img src=images/duihao.jpg>";
  }else{
   fdo.classname = "framedivwarn";
   ido.innerhtml = icon + s;
  }
 }
 //======================================================;
 function loadcheck(){
  if(trim($f('usrinput')).length == 0) return;
  $("checkbtn").disabled = true;
  var o = $("checkdiv");
  o.innerhtml = getloadinfo(); 
  loadajaxdata("reg.php",{usr:$f('usrinput')},successcheck,errorcheck);
  
 }
 function successcheck(v){
  var o = $("checkdiv");
  o.innerhtml = getcheckhtml(v.responsetext);
 }
 function errorcheck(){
  $("checkbtn").disabled = false;
  var o = $("checkdiv");
  o.innerhtml = geterrorinfo();
 }
 function getcheckhtml(s){
  s = (s == "1")? "恭喜您,用户名可以注册!":"对不起,该用户名已经被注册!";
  return s;
   }
 //======================================================;
 function getloadinfo(){
  return '正在加载数据...';
 }
 function geterrorinfo(){
  return '数据加载失败!';
 }
 //======================================================;
 function initpage(){
  for(var i=0;i<ns.length;i++){
   $(ns[i]+"input").value = "";
  }
 }
 function checksignup() {
if ( document.formsignup.reauthnum.value == '' ) {
window.alert('请输入认证码!!');
document.formsignup.reauthnum.focus();
return false;
}
return true;
}
function isallow_jewellry(){
        if(document.formsignup.agree.checked == false){
            document.formsignup.submit.disabled = true;
            }else if(document.formsignup.agree.checked == true){
            document.formsignup.submit.disabled = false;
            }
        }

</script>
</head>

<body class="statusbar" onload="initpage();">
<table width="100%" class="wn_login_01">
  <tr>
    <td></td>
  </tr>
</table>
<table width="100%">
  <tr>
    <td height="24"></td>
  </tr>
</table>
<table width="721" align="center">
  <tr>
    <td height="97" class="hyzc-4"></td>
  </tr>
</table>
<table width="721" align="center">
  <tr>
    <td height="22" class="hyzc-5"></td>
  </tr>
</table>
<table width="721" border="0" align="center">
  <tr>
    <td width="4" class="hyzc-7"></td>
    <td width="713" height="28"></td>
    <td width="4" class="hyzc-7"></td>
  </tr>
</table>
<table width="721" border="0" align="center">
  <tr>
    <td width="4" class="hyzc-7"></td>
    <td class="hyzc-8">请注册会员,只有会员才能发表贴子,游客可以回贴和使用快捷回复功能!</td>
    <td width="4" class="hyzc-7"></td>
  </tr>
</table>
<table width="721" border="0" align="center">
  <tr>
    <td width="4" class="hyzc-7"></td>
    <td width="713" height="25"></td>
    <td width="4" class="hyzc-7"></td>
  </tr>
</table>
<table width="721" border="0" align="center">
  <tr>
    <td width="4" class="hyzc-7"></td>
    <td width="45"></td>
    <td width="420"><font class="hyzc-1-1">提示:</font><font class="hyzc-9">如果您已经注册了会员,请跳过此步骤,直接点这里</font></td>
    <td width="248"><form id="form1" name="form1" method="post" action="">
      <input type="image" name="imagefield" src="images/hyzc-3.jpg" />
    </form>
    </td>
    <td width="4" class="hyzc-7"></td>
  </tr>
</table>
<table width="721" border="0" align="center">
  <tr>
    <td width="4" class="hyzc-7"></td>
    <td width="713" height="18"></td>
    <td width="4" class="hyzc-7"></td>
  </tr>
</table>
<table width="721" align="center">
  <tr>
    <td width="4" class="hyzc-7"></td>
    <td width="30"></td>
    <td width="653" height="1" class="hyzc-1-2"></td>
    <td width="30"></td>
    <td width="4" class="hyzc-7"></td>
  </tr>
</table>
<table width="721" border="0" align="center">
  <tr>
    <td width="4" class="hyzc-7"></td>
    <td width="713" height="18"></td>
    <td width="4" class="hyzc-7"></td>
  </tr>
</table>
<form id="form2" name="formsignup" method="post" action="" >
<table width="721" border="0" align="center">
  <tr>
    <td width="4" class="hyzc-7"></td>
    <td width="45"></td>
    <td width="130"><font class="hyzc-1-1">填写登录名和密码</font>&nbsp;&nbsp;<font class="hyzc-6">*</font></td>
    <td width="85" align="right">登录名:</td>
    <td class="hyzc-1-5">
    <span class="framedivnormal" id="usrframediv">
    <input type="text" name="usrinput" id="usrinput" class="hyzc-1-3" onkeyup="checkusr(this.value);changeusr();" onfocus="checkusr(this.value);">&nbsp;&nbsp;<span id="usrinfodiv" class="hyzc-6"></span></span>
    </td>
    <td width="4" class="hyzc-7"></td>
  <tr><tr height=30><td class="hyzc-7"></td><td></td><td></td><td></td><td valign=bottom>&nbsp;&nbsp;<input name="checkbtn" type="button" id="checkbtn" onclick="loadcheck();" value="检测用户名是否可用">&nbsp;&nbsp;&nbsp;<span id="checkdiv"></span></td><td class="hyzc-7"></td></tr>
</table>
<table width="721" border="0" align="center"><tr><td width="4" class="hyzc-7"></td><td width="713" height="8"></td><td width="4" class="hyzc-7"></td></table>

<table width="721" border="0" align="center">
  <tr>
    <td width="4" class="hyzc-7"></td>
    <td width="165"></td>
    <td width="10"><font class="hyzc-6">*</font></td>
    <td width="90" align="right">输入登录密码:&nbsp;</td>
    <td><span class="framedivnormal" id="pwdframediv"> <input name="pwdinput" type="password" id="pwdinput" maxlength="16" onkeyup="checkpwd(this.value);" onfocus="checkpwd(this.value);" class="hyzc-1-3">&nbsp;&nbsp;<span id="pwdinfodiv" class="hyzc-6"></span>
      </span>
      </td>
    <td width="4" class="hyzc-7"></td>
  </tr>     
  <tr height=30><td class="hyzc-7"></td><td></td><td></td><td></td><td><script language="javascript">
  var ps = new passwordstrength();
  ps.setsize("200","22");
 </script></td><td class="hyzc-7"></td></tr>
</table>
<table width="721" border="0" align="center">
  <tr>
    <td width="4" class="hyzc-7"></td>
    <td width="713" height="5"></td>
    <td width="4" class="hyzc-7"></td>
  </tr>
</table>
<table width="721" border="0" align="center">
  <tr>
    <td width="4" class="hyzc-7"></td>
    <td width="165"></td>
    <td width="10"><font class="hyzc-6">*</font></td>
    <td width="90" align="right">再次输入密码:&nbsp;</td>
    <td >
    <span class="framedivnormal" id="repwdframediv"><input name="repwdinput" type="password" id="repwdinput" maxlength="16" onkeyup="checkpwd2(this.value);" onfocus="checkpwd2(this.value);" class="hyzc-1-3">&nbsp;&nbsp;
    <span id="repwdinfodiv" class="hyzc-6"></span>
    </span>
    </td>
    <td width="4" class="hyzc-7"></td>
  </tr>
</table>
<table width="721" border="0" align="center">
  <tr>
    <td width="4" class="hyzc-7"></td>
    <td width="713" height="5"></td>
    <td width="4" class="hyzc-7"></td>
  </tr>
</table>

<table width="721" align="center">
  <tr>
    <td width="4" class="hyzc-7"></td>
    <td width="30"></td>
    <td width="653" height="1" class="hyzc-1-2"></td>
    <td width="30"></td>
    <td width="4" class="hyzc-7"></td>
  </tr>
</table>
<table width="721" border="0" align="center">
  <tr>
    <td width="4" class="hyzc-7"></td>
    <td width="713" height="20"></td>
    <td width="4" class="hyzc-7"></td>
  </tr>
</table>
<table width="721" border="0" align="center">
  <tr>
    <td width="4" class="hyzc-7"></td>
    <td width="45"></td>
    <td width="120"><font class="hyzc-1-1">填写个人资料信息</font></td>
    <td width="10"><font class="hyzc-6">*</font></td>
    <td width="90" align="right">邮箱:&nbsp;</td>
    <td><span class="framedivnormal" id="emlframediv"><input name="emlinput" type="text" id="emlinput" onfocus="checkeml(this.value);" onkeyup="checkeml(this.value);" maxlength="40" class="hyzc-1-3">&nbsp;&nbsp;
    <span id="emlinfodiv" class="hyzc-6"></span>
    </span>
    </td>
    <td width="4" class="hyzc-7"></td>
  </tr>
</table>
<table width="721" border="0" align="center">
  <tr>
    <td width="4" class="hyzc-7"></td>
    <td width="713" height="5"></td>
    <td width="4" class="hyzc-7"></td>
  </tr>
</table>
<table width="721" border="0" align="center">
  <tr>
    <td width="4" class="hyzc-7"></td>
    <td width="45"></td>
    <td width="120"></td>
    <td width="10"></td>
    <td width="85" align="right">性别:</td>
    <td width="175" class="hyzc-1-5"><input name="radiobutton" type="radio" value="radiobutton" checked="checked" />
    男<input type="radio" name="radiobutton" value="radiobutton" />
    女</td>
    <td width="270"></td>
    <td width="4" class="hyzc-7"></td>
  </tr>
</table>
<table width="721" border="0" align="center">
  <tr>
    <td width="4" class="hyzc-7"></td>
    <td width="713" height="15"></td>
    <td width="4" class="hyzc-7"></td>
  </tr>
</table>
<table width="721" border="0" align="center">
  <tr>
    <td width="4" class="hyzc-7"></td>
    <td width="45"></td>
    <td width="120"></td>
    <td width="10"></td>
    <td width="85" align="right">出生日期:</td>
    <td width="225" class="hyzc-1-5">
      <select name="select">
   <option value="1">1900</option>
   <option value="1">2009</option>
      </select>年
   <select name="select">
   <option value="1">01</option>
   <option value="1">02</option>
   <option value="1">03</option>
   <option value="1">04</option>
   <option value="1">05</option>
   <option value="1">06</option>
   <option value="1">07</option>
   <option value="1">08</option>
   <option value="1">09</option>
   <option value="1">10</option>
   <option value="1">11</option>
   <option value="1">12</option>
      </select>月
   <select name="select">
   <option value="1">01</option>
   <option value="2">02</option>
   <option value="3">03</option>
   <option value="4">04</option>
   <option value="5">05</option>
   <option value="6">06</option>
   <option value="7">07</option>
   <option value="8">08</option>
   <option value="9">09</option>
   <option value="10">10</option>
   <option value="11">11</option>
   <option value="12">12</option>
   <option value="13">13</option>
   <option value="14">14</option>
   <option value="15">15</option>
   <option value="16">16</option>
   <option value="17">17</option>
   <option value="18">18</option>
   <option value="19">19</option>
   <option value="20">20</option>
   <option value="21">21</option>
   <option value="22">22</option>
   <option value="23">23</option>
   <option value="24">24</option>
   <option value="25">25</option>
   <option value="26">26</option>
   <option value="27">27</option>
   <option value="28">28</option>
   <option value="29">29</option>
   <option value="30">30</option>
   <option value="31">31</option>
    </select>日    </td>
    <td width="220"></td>
    <td width="4" class="hyzc-7"></td>
  </tr>
</table>
<table width="721" border="0" align="center">
  <tr>
    <td width="4" class="hyzc-7"></td>
    <td width="713" height="15"></td>
    <td width="4" class="hyzc-7"></td>
  </tr>
</table>
<table width="721" border="0" align="center">
  <tr>
    <td width="4" class="hyzc-7"></td>
    <td width="45"></td>
    <td width="120"></td>
    <td width="10"><font class="hyzc-6">*</font></td>
    <td width="85" align="right">验证码:</td>
    <td width="112" class="hyzc-1-5">
      <input type="text" name="reauthnum" class="hyzc-1-6" />    </td>
    <td width="74"><img src="images/authimg.png"></td>
    <td width="262"><a href="#" class="hyzc-3">看不清图片</a></td>
    <td width="4" class="hyzc-7"></td>
  </tr>
</table>
<table width="721" border="0" align="center">
  <tr>
    <td width="4" class="hyzc-7"></td>
    <td width="713" height="20"></td>
    <td width="4" class="hyzc-7"></td>
  </tr>
</table>
<table width="721" align="center">
  <tr>
    <td width="4" class="hyzc-7"></td>
    <td width="30"></td>
    <td width="653" height="1" class="hyzc-1-2"></td>
    <td width="30"></td>
    <td width="4" class="hyzc-7"></td>
  </tr>
</table>
<table width="721" border="0" align="center">
  <tr>
    <td width="4" class="hyzc-7"></td>
    <td width="713" height="20"></td>
    <td width="4" class="hyzc-7"></td>
  </tr>
</table>
<table width="721" border="0" align="center">
  <tr>
    <td width="4" class="hyzc-7"></td>
    <td width="45"></td>
    <td width="120"></td>
    <td width="15"><font class="hyzc-6">*</font></td>
    <td width="30"><input name="agree" type="checkbox" class="hyzc-1-7" value="1" checked="checked" onclick="isallow_jewellry()"/></td>
    <td width="503">我已经看过并同意<a href="#" class="hyzc-1-8">《人民在线论坛网络服务使用协议》</a></td>
    <td width="4" class="hyzc-7"></td>
  </tr>
</table>
<table width="721" border="0" align="center">
  <tr>
    <td width="4" class="hyzc-7"></td>
    <td width="713" height="15"></td>
    <td width="4" class="hyzc-7"></td>
  </tr>
</table>
<table width="721" border="0" align="center">
  <tr>
    <td width="4" class="hyzc-7"></td>
    <td width="45"></td>
    <td width="110"></td>
    <td width="558"><textarea name="textarea" class="hyzc-1-9" readonly="readonly">
</textarea></td>
    <td width="4" class="hyzc-7"></td>
  </tr>
</table>
<table width="721" border="0" align="center">
  <tr>
    <td width="4" class="hyzc-7"></td>
    <td width="713" height="40"></td>
    <td width="4" class="hyzc-7"></td>
  </tr>
</table>
<table width="721" border="0" align="center">
  <tr>
    <td width="4" class="hyzc-7"></td>
    <td width="45"></td>
    <td width="240"></td>
    <td><input type="submit" name="submit" value="提交确认" tabindex="1" onclick='javascript:return checksignup()'></td>
    <td width="4" class="hyzc-7"></td>

  </tr>
</table>
<table width="721" border="0" align="center">
  <tr>
    <td width="4" class="hyzc-7"></td>
    <td width="713" height="40"></td>
    <td width="4" class="hyzc-7"></td>
  </tr>
</table>
<table width="721" align="center">
  <tr>
    <td class="wn_login_02_06"></td>
  </tr>
</table>
</form>
</body>
</html>

下面为js文件代码
<script language="javascript" >
//js/common.js
//引用js/css文件;
function include(path,type,title){
 var s,i,t;
 if(arguments.length < 1){
  return ;
 }
 if(arguments.length == 1){
  type = "js";
 }
 switch(type.tolowercase()){
  case "css":
    t = document.getelementsbytagname("link");
    for(i=0;i<t.length;i++){
     if(t[i].href && t[i].href.indexof(path)!=-1){
      return;
     }
    }
    s=document.createelement("link");
    s.rel="alternate stylesheet";
    s.type="text/css";
    s.href=path;
    s.title=title;
    s.disabled=false;
    break;
  case "js":
  case "javascript":
  default:
    t = document.getelementsbytagname("script");
    for(i=0;i<t.length;i++){
     if(t[i].src && t[i].src.indexof(path)!=-1){
      return;
     }
    }
    s=document.createelement("script");
    s.type="text/javascript";
    s.src=path;
   break;
 }
 var h=document.getelementsbytagname("head")[0];
 h.appendchild(s);
}
//字符处理;
//去左右空格;
function trim(s){
  return rtrim(ltrim(s));
}
//去左空格;
function ltrim(s){
  return s.replace( /^s*/, "");
}
//去右空格;
function rtrim(s){
  return s.replace( /s*$/, "");
}
//验证信息;
//空字符值;
function isempty(s){
 s = trim(s);
 return s.length == 0;
}
//email;
function isemail(s){
 s = trim(s);
  var p = /^[_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.){1,4}[a-z]{2,3}$/i;
  return p.test(s);
}
//数字;
function isnumber(s){
 return !isnan(s);
}
//颜色值;
function iscolor(s){
 s = trim(s);
 if (s.length !=7) return false;
 return s.search(/#[a-fa-f0-9]{6}/) != -1;
}
//手机号码;
function ismobile(s){
 s = trim(s);
 var p = /13d{9}/;
 return p.test(s);
}
//身份证;
function iscard(s){
 s = trim(s);
 var p = /^d{15}(d{2}[xx0-9])?$/;
 return p.test(s);
}
//url;
function isurl(s){
 s = trim(s).tolowercase();
 var p = /^http://[a-za-z0-9]+.[a-za-z0-9]+[/=?%-&_~`@[]':+!]*([^<>""])*$/;
 return p.test(s);
}
//phone;
function isphone(s){
 s = trim(s);
 var p = /^(((d{3}))|(d{3}-))?((0d{2,3})|0d{2,3}-)?[1-9]d{6,7}$/;
 return p.test(s);
}
//zip;
function iszip(s){
 s = trim(s);
 var p = /^[1-9]d{5}$/;
 return p.test(s);
}
//double;
function isdouble(s){
 s = trim(s);
 var p = /^[-+]?d+(.d+)?$/;
 return p.test(s);
}
//integer;
function isinteger(s){
 s = trim(s);
 var p = /^[-+]?d+$/;
 return p.test(s);
}
//english;
function isenglish(s){
 s = trim(s);
 var p = /^[a-za-z]+$/;
 return p.test(s);
}
//中文;
function ischinese(s){
 s = trim(s);
 var p = /^[u0391-uffe5]+$/;
 return p.test(s);
}
//双字节
function isdoublechar(s){
 var p = /^[^x00-xff]+$/;
 return p.test(s);
}
//含有中文字符
function haschinesechar(s){
 var p = /[^x00-xff]/;
 return p.test(s);
}
function hasaccountchar(s){
 var p = /^[a-za-z0-9][a-za-z0-9_-]{0,15}$/;
 return p.test(s);
}
function limitlen(s,min,max){
 s=trim(s);
 if(s=="") return false;
 if((s.length<min)||(s.length>max))
  return false;
 else
  return true;
}
//功能;
//延时事件;
function setdeferevent(type,action,time){
 if (trim(time).length == 0) time = 1;
 if (typeof(time)!="number") time = 1;
 
 switch(type.tolowercase()){
  case "go":
   window.settimeout("window.location='"+ action +"'",time);
   break;
  case "alert":
   window.settimeout("alert('"+ action +"')",time);
   break;
  case "js":
  case "javascript":
   window.settimeout("'"+ action.tostring() +"'",time);
   break;
  default:
   alert("nothing will do!");
   break
 }  
}
function addloadlistener(handler){
 if (typeof window.addeventlistener != 'undefined')
  window.addeventlistener('load', handler, false);
 else if (typeof document.addeventlistener != 'undefined')
  document.addeventlistener('load', handler, false);
 else if (typeof window.attachevent != 'undefined')
  window.attachevent('onload', handler);
};
function addeventlistener(element, eventtype, handler, capture)
{
 try
 {
  if (element.addeventlistener)
   element.addeventlistener(eventtype, handler, capture);
  else if (element.attachevent)
   element.attachevent("on" + eventtype, handler);
 }
 catch (e) {}
};

function removeeventlistener(element, eventtype, handler, capture)
{
 try
 {
  if (element.removeeventlistener)
   element.removeeventlistener(eventtype, handler, capture);
  else if (element.detachevent)
   element.detachevent("on" + eventtype, handler);
 }
 catch (e) {}
};
//image;
function preloadimages(){
 var d = document;
 if(d.images){
  if(!d.p_i_a) d.p_i_a = new array();
  var i,j=d.p_i_a.length,a=arguments;
  for(i=0;i<a.length;i++){
   d.p_i_a[j]= new image();
   d.p_i_a[j++].src = a[i];
  }
 }
}
//ajax功能;
function loadajaxelement(e,u,p,f,l){
 if(arguments.length < 3){
  return ;
 }
 o = $(e);
 o.innerhtml = l;
 p = $h(p).toquerystring();
 new ajax.updater(     
                    {success: e},
                    u,
                    {method: 'get', parameters: p, onfailure: f});
}
function loadajaxdata(u,p,s,f){
 if(arguments.length < 3){
  return ;
 }
 p = $h(p).toquerystring();
 new ajax.request(     
                    u,
                    {method: 'get', parameters: p, onsuccess:s,onfailure: f});
}
function sendajaxelement(e,u,p,f,l){
 if(arguments.length < 3){
  return ;
 }
 o = $(e);
 o.innerhtml = l;
 p = $h(p).toquerystring();
 new ajax.updater(     
                    {success: e},
                    u,
                    {method: 'post', parameters: p, onfailure: f});
}
function sendajaxdata(u,p,s,f){
 if(arguments.length < 3){
  return ;
 }
 p = $h(p).toquerystring();
 new ajax.request(     
                    u,
                    {method: 'post', parameters: p, onsuccess:s,onfailure: f});
}
</script>

<script language="javascript" >
//js/prototype.js
/*
这个文章你可以到jquery官网去下载哦。或到
http://www.111cn.net/js/prototype.js 下载
*/
</script>
<script language="javascript" >
//js/passwordstrength.js
//密码强度;
function passwordstrength(showed){ 
 this.showed = (typeof(showed) == "boolean")?showed:true;
 this.styles = new array(); 
 this.styles[0] = {backgroundcolor:"#ebebeb",borderleft:"solid 1px #ffffff",borderright:"solid 1px #bebebe",borderbottom:"solid 1px #bebebe"}; 
 this.styles[1] = {backgroundcolor:"#ff4545",borderleft:"solid 1px #ffffff",borderright:"solid 1px #bb2b2b",borderbottom:"solid 1px #bb2b2b"};
 this.styles[2] = {backgroundcolor:"#ffd35e",borderleft:"solid 1px #ffffff",borderright:"solid 1px #e9ae10",borderbottom:"solid 1px #e9ae10"};
 this.styles[3] = {backgroundcolor:"#95eb81",borderleft:"solid 1px #ffffff",borderright:"solid 1px #3bbc1b",borderbottom:"solid 1px #3bbc1b"};
 
 this.labels= ["弱","中","强"];

 this.divname = "pwd_div_"+math.ceil(math.random()*100000);
 this.minlen = 6;
 
 this.width = "150px";
 this.height = "16px";
 
 this.content = "";
 
 this.selectedindex = 0;
 
 this.init(); 
}
passwordstrength.prototype.init = function(){
 var s = '<table cellpadding="0" id="'+this.divname+'_table" cellspacing="0" style="width:'+this.width+';height:'+this.height+';">';
 s += '<tr>';
 for(var i=0;i<3;i++){
  s += '<td id="'+this.divname+'_td_'+i+'" width="33%" align="center"><span style="font-size:1px">&nbsp;</span><span id="'+this.divname+'_label_'+i+'" style="display:none;font-family: courier new, courier, mono;font-size: 12px;color: #000000;">'+this.labels[i]+'</span></td>';
 } 
 s += '</tr>';
 s += '</table>';
 this.content = s;
 if(this.showed){
  document.write(s);
  this.copytostyle(this.selectedindex);
 } 
}
passwordstrength.prototype.copytoobject = function(o1,o2){
 for(var i in o1){
  o2[i] = o1[i];
 }
}
passwordstrength.prototype.copytostyle = function(id){
 this.selectedindex = id;
 for(var i=0;i<3;i++){
  if(i == id-1){
   this.$(this.divname+"_label_"+i).style.display = "inline";
  }else{
   this.$(this.divname+"_label_"+i).style.display = "none";
  }
 }
 for(var i=0;i<id;i++){
  this.copytoobject(this.styles[id],this.$(this.divname+"_td_"+i).style);   
 }
 for(;i<3;i++){
  this.copytoobject(this.styles[0],this.$(this.divname+"_td_"+i).style);
 }
}
passwordstrength.prototype.$ = function(s){
 return document.getelementbyid(s);
}
passwordstrength.prototype.setsize = function(w,h){
 this.width = w;
 this.height = h;
}
passwordstrength.prototype.setminlength = function(n){
 if(isnan(n)){
  return ;
 }
 n = number(n);
 if(n>1){
  this.minlength = n;
 }
}
passwordstrength.prototype.setstyles = function(){
 if(arguments.length == 0){
  return ;
 }
 for(var i=0;i<arguments.length && i < 4;i++){
  this.styles[i] = arguments[i];
 }
 this.copytostyle(this.selectedindex);
}
passwordstrength.prototype.write = function(s){
 if(this.showed){
  return ;
 }
 var n = (s == 'string') ? this.$(s) : s;
 if(typeof(n) != "object"){
  return ;
 }
 n.innerhtml = this.content;
 this.copytostyle(this.selectedindex);
}
passwordstrength.prototype.update = function(s){
 if(s.length < this.minlen){
  this.copytostyle(0);
  return;
 }
 var ls = -1;
 if (s.match(/[a-z]/ig)){
  ls++;
 }
 if (s.match(/[0-9]/ig)){
  ls++;
 }
  if (s.match(/(.[^a-z0-9])/ig)){
  ls++;
 }
 if (s.length < 6 && ls > 0){
  ls--;
 }
  switch(ls) {
   case 0:
    this.copytostyle(1);
    break;
   case 1:
    this.copytostyle(2);
    break;
   case 2:
    this.copytostyle(3);
    break;
   default:
    this.copytostyle(0);
  }
}
</script>

//reg.php
<?php

$a="wyjboy";
if($a == "$usr"){
echo 0;
}else{
echo 1;
}
?>

[!--infotagslink--]

相关文章

  • php无刷新利用iframe实现页面无刷新上传文件(1/2)

    利用form表单的target属性和iframe 一、上传文件的一个php教程方法。 该方法接受一个$file参数,该参数为从客户端获取的$_files变量,返回重新命名后的文件名,如果上传失...2016-11-25
  • Php文件上传类class.upload.php用法示例

    本文章来人大家介绍一个php文件上传类的使用方法,期望此实例对各位php入门者会有不小帮助哦。 简介 Class.upload.php是用于管理上传文件的php文件上传类, 它可以帮...2016-11-25
  • PHP文件上传一些小收获

    又码了一个周末的代码,这次在做一些关于文件上传的东西。(PHP UPLOAD)小有收获项目是一个BT种子列表,用户有权限上传自己的种子,然后配合BT TRACK服务器把种子的信息写出来...2016-11-25
  • jQuery实现简单的文件上传进度条效果

    本文实例讲述了jQuery实现文件上传进度条效果的代码。分享给大家供大家参考。具体如下: 运行效果截图如下:具体代码如下:<!DOCTYPE html><html><head><meta charset="utf-8"><title>upload</title><link rel="stylesheet...2015-11-24
  • jQuery+PHP发布的内容进行无刷新分页(Fckeditor)

    这篇文章将使用jQuery,并结合PHP,将Fckeditor发布的内容进行分页,并且实现无刷新切换页面。 本文假设你是WEB开发人员,掌握了jQuery和PHP相关知识,并且熟知Fckeditor的配置和使用。...2015-10-23
  • php文件上传你必须知道的几点

    本篇文章主要说明的是与php文件上传的相关配置的知识点。PHP文件上传功能配置主要涉及php.ini配置文件中的upload_tmp_dir、upload_max_filesize、post_max_size等选项,下面一一说明。打开php.ini配置文件找到File Upl...2015-10-21
  • 解决vue刷新页面以后丢失store的数据问题

    这篇文章主要介绍了解决vue刷新页面以后丢失store的数据问题,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2020-08-12
  • 解决vuex数据页面刷新后初始化操作

    这篇文章主要介绍了解决vuex数据页面刷新后初始化操作,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2020-07-26
  • java后台实现js关闭本页面,父页面指定跳转或刷新操作

    这篇文章主要介绍了java后台实现js关闭本页面,父页面指定跳转或刷新操作,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2020-11-16
  • 借助FileReader实现将文件编码为Base64后通过AJAX上传

    这篇文章主要介绍了借助FileReader实现将文件编码为Base64后通过AJAX上传的方法,包括后端对文件数据解码并保存的PHP代码,需要的朋友可以参考下...2015-12-25
  • php+ajax制作无刷新留言板

    本文就是和大家分享一款由php结合ajax实现的无刷新留言板,先给大家看一下最后的效果图:数据库连接代码如下: <&#63;php$conn = @mysql_connect("localhost","root","root") or die ("MySql连接错误");mysql_select_db("d...2015-10-30
  • 基于jquery实现表格无刷新分页

    这篇文章主要介绍了基于jquery实现表格无刷新分页,功能实现了前端排序功能,增加了前端搜索功能,感兴趣的小伙伴们可以参考一下...2016-01-08
  • js实现上传文件添加和删除文件选择框

    这篇文章主要为大家详细介绍了js实现上传文件添加和删除文件选择框 ,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...2016-10-25
  • jQuery+ajax简单实现文件上传的方法

    这篇文章主要介绍了jQuery+ajax简单实现文件上传的方法,结合实例形式简单分析了jQuery基于ajax的post方法进行文件传输及asp.net后台处理技巧,需要的朋友可以参考下...2016-06-12
  • vue实现在进行增删改操作后刷新页面

    这篇文章主要介绍了vue实现在进行增删改操作后刷新页面,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2020-08-05
  • Vue 中获取当前时间并实时刷新的实现代码

    这篇文章主要介绍了Vue 中获取当前时间并实时刷新,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下...2020-05-13
  • 适用于初学者的简易PHP文件上传类

    本文实例讲述了PHP多文件上传类,分享给大家供大家参考。具体如下:<&#63;phpclass Test_Upload{ protected $_uploaded = array(); protected $_destination; protected $_max = 1024000; protected $_messages =...2015-10-30
  • C#实现刷新桌面的方法

    这篇文章主要介绍了C#实现刷新桌面的方法,涉及C#基于shell32.dll动态链接库实现系统桌面刷新的技巧,具有一定参考借鉴价值,需要的朋友可以参考下...2020-06-25
  • js 实现文件上传样式详情

    这篇文章主要介绍了js 实现文件上传样式,下面文章举例说明js 是如何实现文件上传样式的,附有代码详细解说,需要的朋友可以参考一下,希望对你有所帮助...2021-10-21
  • 纯javascript实现简单下拉刷新功能

    代码很简单,实现的功能却很实用,直接奉上代码CSS:复制代码 代码如下: <meta charset="utf-8" /> <title>Pull to Refresh</title> <meta name="viewport" content="width=device-width,height=device-height,inital-scal...2015-03-15