-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex_newhtml.html
50 lines (41 loc) · 1.5 KB
/
index_newhtml.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
38
39
40
41
42
43
44
45
46
47
48
49
50
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Patient Admission Form</title>
<style>
.error { color: red; }
</style>
</head>
<body>
<h2>Patient Admission Form</h2>
<form id="admissionForm" onsubmit="return validateForm()">
<label for="fullName">Full Name:</label><br>
<input type="text" id="fullName" name="fullName" required><br><br>
<label for="age">Age:</label><br>
<input type="number" id="age" name="age" required><br><br>
<label for="mobileNumber">Mobile Number:</label><br>
<input type="text" id="mobileNumber" name="mobileNumber" required><br>
<span id="mobileNumberError" class="error"></span><br><br>
<input type="submit" value="Submit">
</form>
<script>
function validateForm() {
var fullName = document.getElementById("fullName").value;
var age = document.getElementById("age").value;
var mobileNumber = document.getElementById("mobileNumber").value;
var isValid = true;
var mobileNumberPattern = /^\d{10}$/; // regex pattern for 10-digit mobile number
// Check if mobile number is valid
if (!mobileNumberPattern.test(mobileNumber)) {
document.getElementById("mobileNumberError").innerHTML = "Please enter a valid 10-digit mobile number";
isValid = false;
} else {
document.getElementById("mobileNumberError").innerHTML = "";
}
return isValid;
}
</script>
</body>
</html>