检查密码和确认密码的JavaScript

function checkPassword()
 {
  if(document.getElementById("password").value==null||document.getElementById("password").value=="")
  {
   document.getElementById("spanPassword").innerHTML = "<font color='red'>请输入密码 *</font>";
   return false;
  }
  document.getElementById("spanPassword").innerHTML = "<font color='red'>*</font>";
 }
 
 function checkPasswordConfig()
 {
  var a=document.getElementById("password").value;
  var b=document.getElementById("passwordConfig").value;
  
  if(b==null||b=="")
  {
   document.getElementById("spanPasswordConfig").innerHTML = "<font color='red'>请您确认密码! *</font>";
   return false;
  }
  if(a!=b)
  {
   document.getElementById("spanPasswordConfig").innerHTML = "<font color='red'>您两次输入的密码不一致! *</font>";
   return false;
  }
  
  document.getElementById("spanPasswordConfig").innerHTML = "<font color='red'>*</font>";
 }

posted on 2013-06-02 21:51  大胡子青松  阅读(977)  评论(0编辑  收藏  举报

导航