0% found this document useful (0 votes)
3 views2 pages

WAP To Design Registration Number Form Using HTML

The document is an HTML form for user registration that includes fields for first name, last name, password, email, phone number, and address. It utilizes JavaScript for form validation, ensuring that inputs meet specific criteria such as minimum character lengths and proper formats. Alerts are triggered for any validation failures before the form can be submitted.

Uploaded by

ashuuchauhan108
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

WAP To Design Registration Number Form Using HTML

The document is an HTML form for user registration that includes fields for first name, last name, password, email, phone number, and address. It utilizes JavaScript for form validation, ensuring that inputs meet specific criteria such as minimum character lengths and proper formats. Alerts are triggered for any validation failures before the form can be submitted.

Uploaded by

ashuuchauhan108
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

<!

—WAP to design registration number form using HTML+Java Script -- >


<html>
<head>
<title>mypage</title>
<script>
function validateForm()
{
var firstname=document.getElementById("fname").value.trim();
var namePattern=/^[A-Za-z ]+$/;
if(firstname.length < 6 || !namePattern.test(firstname))
{
alert("Minimum character length for first name is 6 characters");
return false;
}
var lastname=document.getElementById("lname").value.trim();
if(lastname=="")
{
alert("Last Name should not be empty");
return false;
}
var password=document.getElementById("password").value.trim();
if(password.length < 6 )
{
alert("Password should be at least 6 characters");
return false;
}
var email=document.getElementById("email").value.trim();
var emailPattern=/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$/;
if(!emailPattern.test(email))
{
alert("Your email format is wrong");
return false;
}
var phone=document.getElementById("phone").value.trim();
var phonePattern=/^[0-9]{10}$/;
if(!phonePattern.test(phone))
{
alert("Phone number should be 10 digits");
return false;
}
var address=document.getElementById("add").value.trim();
if(address=="")
{
alert("Address should not be empty");
return false;
}
if(address.length > 50)
{
alert("Address should not exceed 50 characters");
return false;
}
return true;
}
</script>
</head>
<body>
<form onsubmit="return validateForm()">
First Name:<input type="text" id="fname"><br><br>
Last Name:<input type="text" id="lname"><br><br>
Password:<input type="password" id="password"><br><br>
Email:<input type="text" id="email"><br><br>
Phone:<input type="number" id="phone"><br><br>
Address:<textarea id="add" maxlength="50"></textarea><br><br>
<input type="submit" value="registration">
</form>
</body>
</html>

You might also like