-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
94 lines (82 loc) · 3.42 KB
/
index.html
File metadata and controls
94 lines (82 loc) · 3.42 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SUBMIT FORM</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
</head>
</head>
<style>
.container{
margin-top: 5%;
}
label::after{
content: "*";
color: red;
}
</style>
<script src="./dist/index.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
<body>
<div class="row">
<h2 style="text-align: center;">
Submit Form
</h2>
<button class="col-md-4 btn btn-primary" type="button" onclick="getName()">Hii</button>
<p id="fullName">Bye</p>
<div class="col-md-3"></div>
<div class="col-md-6">
<div class="container">
<div class="mb-3">
<label for="name" class="form-label">First Name</label>
<input type="text" class="form-control" placeholder="Enter First Name" id="name" autocomplete="off">
</div>
<div class="mb-3">
<label for="email" class="form-label">Email Id</label>
<input type="email" class="form-control" placeholder="Enter Email Id" id="email" autocomplete="off">
</div>
<div class="mb-3">
<button type="submit" class="btn btn-outline-success" onclick="validateAdd()">Submit</button>
</div>
</div>
</div>
<div class="col-md-3"></div>
<br>
<div class="col-md-3"></div>
<div class="col-md-6">
<div class="alert alert-warning alert-dismissible fade show" role="alert" style="display: none;" id="alert">
<strong><p id="message" style="text-align: center;"></p></strong>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
<div class="col-md-3"></div>
</div>
</div>
</body>
<script>
function getName(){
document.getElementById('fullName').innerText = getFullName('Ankit','Mishra');
}
function validateAdd (){
const pattern = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
document.getElementById("message").innerText = "";
document.getElementById("alert").style.display = "none";
let name = document.getElementById("name").value;
let email = document.getElementById("email").value;
if (name == null || name == '') {
alert(" Please, Enter your First Name"); return;
}
if(email == null || email == ''){
alert("Please, Enter your Email Id"); return;
}
if(!pattern.test(email)){
alert("Please enter valid Email Id"); return;
}
let message = `Hey, I am ${name}. My email id is ${email}`;
document.getElementById("alert").style.display = "block";
document.getElementById("message").innerText = message;
document.getElementById("name").value = "";
document.getElementById("email").value = "";
}
</script>
</html>