-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2.2.html
37 lines (34 loc) · 1.31 KB
/
2.2.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Assignment 2 Qn 2</title>
<script>
function validate() {
let x = document.getElementById("roll").value;
var num = /^[0-9]+$/;
if (!x.match(num))
alert("The roll number must be of numeric value!");
else if (x.toString().length != 7)
alert("The length of roll no. must be greater than 7!!!");
else
alert("Valid!");
}
</script>
</head>
<body style="text-align: center;">
<h2>Student Registration form</h2>
<form action="">
<label for="name">Enter your name:</label>
<input type="text" name="name" id="name" placeholder="Your name..."><br><br>
<label for="roll">Enter your Roll Number:</label>
<input type="text" name="roll" id="roll" placeholder="Your roll number..."><br><br>
<label for="course">Enter the courses you attend:</label>
<input type="text" name="course" id="course" placeholder="Your courses..."
style="width: 50ch; height: 10ch;"><br><br>
<input type="submit" onclick="validate()" placeholder="Submit">
</form>
</body>
</html>