JavaScript Password Validation

Advertisements

Prev Tutorial Next Tutorial

JavaScript Password Validation

Here i will show you how to validate any password field like password field can not be blank and length of password is minimum 8 character.

Example

<html>
<head>
<script>
function pass_validation()
{  
var password=document.myform.password.value;  
  
if (password==null || password=="")
{  
  alert("password can't be blank");  
  return false;  
}
else if(password.length<8)
{  
  alert("Password must be at least 8 characters long.");  
  return false;  
  }  
}  

</script>
</head>
<body>
<form name="myform" method="post" action="register.php" onsubmit="return pass_validation()" >  
Password: <input type="password" name="password">  
<input type="submit" value="submit">  
</form>  
</body>
</html>

Result

Password:

Prev Tutorial Next Tutorial

Google Advertisment

Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 9999595223

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

For Projects 9999595223

Google Advertisements


Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs

Advertisements