Skip to content

Commit c2dee1a

Browse files
committed
exercises completed
1 parent 321fe73 commit c2dee1a

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

user-input-with-forms/exercises/index.html

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,34 @@
99
</head>
1010
<body>
1111
<!-- TODO: add form here -->
12-
12+
<form id = "simulationForm" action="https://handlers.education.launchcode.org/request-parrot" method="POST">
13+
<label>Test Name <input type="text" name="testName"></label>
14+
<label>Test Date<input type="date" name="testDate"></label>
15+
<label>Rocket Type<input type="select" name="rocketType"></label>
16+
<label>Number of Rocket Booster<input type="number" name="boosterCount"></label>
17+
<label>Wind Rating<input type ="radio" name="windRating"></label>
18+
<label>Use production grade servers<input type="checkbox" name="productionServers"></label>
19+
<button>Run Simulation</button>
20+
</form>
1321

1422
<p>WARNING: This ONLY works in <b>replit</b> if this "result" page is opened in its own window. Click the icon that shows a box with an arrow coming out of it.
1523
</p>
1624
</body>
1725

1826
</html>
27+
28+
<script>
29+
document.getElementById('simulationForm').addEventListener('submit', function(event) {
30+
var inputs = document.querySelectorAll('input[type="text"], input[type="date"], input[type="number"], input[type="radio"]:checked, input[type="checkbox"]');
31+
for (var i = 0; i < inputs.length; i++) {
32+
if (!inputs[i].value && inputs[i].type !== "checkbox") {
33+
event.preventDefault();
34+
document.getElementById('validationMessage').style.display = 'block';
35+
return;
36+
}
37+
}
38+
});
39+
</script>
40+
</body>
41+
</html>
42+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
//Code Your Solution Below
2+
3+

0 commit comments

Comments
 (0)