0% found this document useful (0 votes)
34 views

Ajay HTML

This document contains the code for a registration form that validates the password entered by the user. It checks that the password field and confirm password field are not empty, that the password length is between 8 to 15 characters, and that the passwords entered in both fields match. If any validation checks fail, error messages are displayed. If all checks pass, a success message is displayed.

Uploaded by

ajay s
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views

Ajay HTML

This document contains the code for a registration form that validates the password entered by the user. It checks that the password field and confirm password field are not empty, that the password length is between 8 to 15 characters, and that the passwords entered in both fields match. If any validation checks fail, error messages are displayed. If all checks pass, a success message is displayed.

Uploaded by

ajay s
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

<html>

<head>

<title> Registration Form </title>

</head>

<script>

function passwordvalidationForm() {

var pass = document.getElementById("pass").value;

var cpass = document.getElementById("cpass").value;

//check empty password field

if(pass == "") {

document.getElementById("message1").innerHTML = "**Fill the password please!";

return false;

//check empty confirm password field

if(cpass == "") {

document.getElementById("message2").innerHTML = "**Enter the password please!";

return false;

//minimum password length validation

if(pass.length < 8) {

document.getElementById("message1").innerHTML = "**Password length must be atleast 8


characters";

return false;

}
//maximum length of password validation

if(pass.length > 15) {

document.getElementById("message1").innerHTML = "**Password length must not exceed 15


characters";

return false;

if(pass != cpass) {

document.getElementById("message2").innerHTML = "**Passwords are not same";

return false;

} else {

alert ("Your password created successfully");

document.write("Registraion form has been submitted successfully");

</script>

<body bgcolor="Lightskyblue">

<br>

<br>

<body>

<form onsubmit ="return passwordvalidationForm()">

<!-- Enter first name -->

<label> First Name* </label>

<input type = "text" id = "fname" value = "">

<br><br>

<!-- Enter last name -->

<label> Last Name </label>


<input type = "text" id = "lname" value = "">

<br><br>

<label>

Course :

</label>

<select>

<option value="Course">Course</option>

<option value="B.E">B.E</option>

<option value="BCA">BCA</option>

<option value="BBA">BBA</option>

<option value="B.Tech">B.Tech</option>

<option value="M.E">M.E</option>

<option value="MBA">MBA</option>

<option value="MCA">MCA</option>

<option value="M.Tech">M.Tech</option>

</select>

<br>

<br>

<label>

Gender :

</label><br>

<input type="radio" name="male"/> Male <br>

<input type="radio" name="female"/> Female <br>

<input type="radio" name="other"/> Other

<br>

<br>

<label>
Phone :

</label>

<input type="text" id="country code" value="+91" size="2"/>

<input type="text" id="phone" size="10"/> <br> <br>

Address

<br>

<textarea cols="80" rows="5" value="address">

</textarea>

<br> <br>

Email:

<input type="email" id="email" value=""/>

<br> <br>

<!-- Create a new password -->

<label> Create Password* </label>

<input type = "password" id = "pass" value = "">

<span id = "message1" style="color:red"> </span> <br><br>

<!-- Enter confirm password -->

<label> Confirm Password* </label>

<input type = "password" id = "cpass" value = "">

<span id = "message2" style="color:red"> </span> <br><br>

<!-- Click to verify valid password -->

<input type = "submit" value = "Submit">

<!-- Click to reset fields -->


<button type = "reset" value = "Reset" >Reset</button>

</form>

</body>

</html>

You might also like