-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
70 lines (65 loc) · 2.13 KB
/
Copy pathindex.html
File metadata and controls
70 lines (65 loc) · 2.13 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
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<title>Apply JavaScript example</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body id="body" onload="alertFunction()">
<!-- <button>Click me</button> -->
<div class="container">
<h1 id="heading">JavaScript Form Validation</h1>
</div>
<form class="myform" action="index.html" method="post" name="myform" onsubmit="return validateForm()">
<div class="form-group">
<label>FirstName</label>
<input type="text" name="firstName" class="form-control">
</div>
<br>
<div class="form-group">
<label>LastName</label>
<input type="text" name="lastName" class="form-control">
</div>
<br>
<div>
<label>Background Color</label>
<select name="background" id="background" onchange="changeColor(this)">
<option value="red">Red</option>
<option value="blue">Blue</option>
<option value="green">Green</option>
</select>
</div>
<br>
<input type="submit" value="Submit"/>
</form>
<script type="text/javascript" src="js/main.js">
// function changeColor(x){
// var heading = document.getElementById('heading');
// heading.style.color = x.value;
// }
//
// function validateForm(){
// var firstName = document.forms['myform']['firstName'].value;
// // alert(firstName);
//
// if (firstName == null || firstName == '') {
// alert("Firstname is empty");
// return false;
// }
// }
// document.addEventListener("DOMContentLoaded", function(){
// function createParagraph(){
// var para = document.createElement('p');
// para.textContent = 'You clicked the button!';
// document.body.appendChild(para);
// }
//
// var buttons = document.querySelectorAll('button');
//
// for(var i = 0; i < buttons.length; i++){
// buttons[i].addEventListener('click', createParagraph);
// }
// });
</script>
</body>
</html>