Tuesday, 7 July 2015

confirm password validation javascript code

<script type="text/javascript">

   function chkform(form)

   {
      if(form.txtpass.value != "" && form.txtpass.value == form.txtconpass.value)
 {
if(form.txtpass.value.length < 8)
{
   alert("at least 8 char allow");
form.txtpass.focus();
return false;
}
//


 re = /[0-9]/;
 if(!re.test(form.txtpass.value))
 {
   alert("please at least one number");
form.txtpass.focus();
return false;

 }

  re = /[a-z]/;
  if(!re.test(form.txtpass.value))
  {
    alert("please at least one lower case");
form.txtpass.focus();
return false;
  }
 


  re = /[A-Z]/;
  if(!re.test(form.txtpass.value))
  {
alert("at least one Upper case");

form.txtpass.focus();
return false;
}
re= /[@$,<>#:?_*&;]/;
if(!re.test(form.txtpass.value))
{
  alert("at least one special char ");
  form.txtpass.focus();
  return false;

   }


 }
 else {
 alert("this feild is required");
 form.txtpass.focus();
 return false;

 }
 return true;
   }
</script>

 <form name="f2" method="post" enctype="multipart/form-data" style=" margin-top: -100px;"  onsubmit="return chkform(this);">
<input type="password" name="txtpass" placeholder="Enter Password"/>
<input type="password" name="txtconpass"  placeholder="Enter Confirm password"/>
</form>


No comments:

Post a Comment