0% found this document useful (0 votes)
20 views3 pages

Deav RSH

This document contains an HTML signup form with JavaScript validation for user input. It checks for a valid registration number, username, password, mobile number, and date of birth, ensuring all fields are filled and conform to specified formats. Alerts are provided for invalid inputs, and successful registration is confirmed upon passing all validations.

Uploaded by

ikkaushik2017
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)
20 views3 pages

Deav RSH

This document contains an HTML signup form with JavaScript validation for user input. It checks for a valid registration number, username, password, mobile number, and date of birth, ensuring all fields are filled and conform to specified formats. Alerts are provided for invalid inputs, and successful registration is confirmed upon passing all validations.

Uploaded by

ikkaushik2017
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

Name : Devarsh Singh

Reg no. : 24BAI0252

<!DOCTYPE html>
<html>
<head>
<title>Signup Form Validation</title>
<script>
function validateForm() {

// Getting values using getElementById (as in PPT)


var regno = [Link]("regno").value;
var username = [Link]("username").value;
var password = [Link]("password").value;
var mobile = [Link]("mobile").value;
var dob = [Link]("dob").value;

// ===== REGULAR EXPRESSIONS =====

// 1. Registration Number (Example: 25BCE0001)


var regPattern = /^[0-9]{2}[A-Z]{3}[0-9]{4}$/;

// 2. Username (No digits allowed)


var userPattern = /^[A-Za-z\s]+$/;

// 3. Password (Min 8 chars, 1 uppercase, 1 lowercase, 1 digit, 1


special char)
var passPattern = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-
Za-z\d@$!%*?&]{8,}$/;

// 4. Mobile Number (Exact 10 digits and not all zeros)


var mobilePattern = /^(?!0{10})[0-9]{10}$/;

// 5. DOB (DDMMYYYY format)


var dobPattern = /^(0[1-9]|[12][0-9]|3[01])(0[1-9]|1[0-2])[0-9]{4}$/;

// ===== VALIDATIONS =====

// Required field check


if (regno == "" || username == "" || password == "" || mobile == ""
|| dob == "") {
alert("All fields marked * are required");
return false;
}
// Registration Number
if (![Link](regno)) {
alert("Invalid Registration Number! Format: 25BCE0001");
return false;
}

// Username
if (![Link](username)) {
alert("Username should not contain digits!");
return false;
}

// Password
if (![Link](password)) {
alert("Password must have minimum 8 characters, including
uppercase, lowercase, digit and special character!");
return false;
}

// Mobile
if (![Link](mobile)) {
alert("Invalid Mobile Number! It must be 10 digits and not all
zeros.");
return false;
}

// DOB
if (![Link](dob)) {
alert("Invalid DOB! Format must be DDMMYYYY");
return false;
}

alert("Registration Successful!");
return true;
}
</script>
</head>

<body>

<h2>Signup Form</h2>

<form onsubmit="return validateForm()">


Registration Number* :
<input type="text" id="regno"><br><br>

Username* :
<input type="text" id="username"><br><br>

Password* :
<input type="password" id="password"><br><br>

Mobile Number* :
<input type="text" id="mobile"><br><br>

Date of Birth (DDMMYYYY)* :


<input type="text" id="dob"><br><br>

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

</form>

</body>
</html>

Output ss :

You might also like