-
Notifications
You must be signed in to change notification settings - Fork 0
/
form_validate.html
37 lines (37 loc) · 1.08 KB
/
form_validate.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 name="viewport" content="width=device-width, initial-scale=1.0">
<title>Form validate</title>
<style>
form{
margin: 10px;
padding: 10px;
}
#fname,#lname,button{
margin: 10px;
padding: 10px;
}
</style>
</head>
<body>
<script>
function getdaata(){
let fname = document.getElementById("fname").value;
let lname = document.getElementById("lname").value;
if(fname==="" && lname===""){
alert("Havent entered anything yer");
}else{
let display_data = `Hello ${fname} ${lname}`;
}
document.write(display_data);
}
</script>
<form action="" onsubmit="return getdaata()">
<input type="text" id="fname" placeholder="First Name"><br>
<input type="text" id="lname" placeholder="Last Name"><br>
<button type="submit">Submit</button>
</form>
</body>
</html>