JavaScript program for Password Validation

In this post you will learn how to check Password validation using JavaScript.This type of code usually use for every Register form.

<html>
<head>
<title> javascript for password validation</title>
<script>
function password_valid()
{
var password=document.myform.password.value;
if(password==null||password=="")
{
alert("password can not be blank");
return false;
}
else if(password.length<8)
{
alert("password must be at least 8 characters long");
return false;
}
}
</script>
<body>
<form name="myform"method="post"action="#"onsubmit="return password_valid()">
Enter password:<input type="password"name="password">
                          <input type="submit"value="submit">
</form>
</body>
</html>
Output:


No comments:

Post a Comment

Basics of CPP Programs

In this post you will learn fundamental C++ programs. These programs for freshers or beginners. 1 .write a cpp program to display hello w...