cleanup
This commit is contained in:
@@ -1,44 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>JS Tester</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<form action="index2.html" method="get">
|
|
||||||
First: <input type="text" name="first">
|
|
||||||
<br>Last: <input type="text" name="last">
|
|
||||||
<br>Age: <input type="number" name="age">
|
|
||||||
<br><input type="submit" value="submit">
|
|
||||||
</form>
|
|
||||||
<script>
|
|
||||||
const form = document.querySelector("form");
|
|
||||||
const email = document.querySelector("#email");
|
|
||||||
form.addEventListener("submit", (e) => {
|
|
||||||
let error = false;
|
|
||||||
if (checker(form.first.value)) {
|
|
||||||
console.log("First Name needed");
|
|
||||||
error = true;
|
|
||||||
}
|
|
||||||
if (checker(form.last.value)) {
|
|
||||||
console.log("Last Name needed");
|
|
||||||
error = true;
|
|
||||||
}
|
|
||||||
if (form.age.value < 19) {
|
|
||||||
console.log("You must be 19 or over");
|
|
||||||
error = true;
|
|
||||||
}
|
|
||||||
if (error) {
|
|
||||||
e.preventDefault();
|
|
||||||
console.log("please review the form");
|
|
||||||
}
|
|
||||||
})
|
|
||||||
function checker(val) {
|
|
||||||
console.log(val.length);
|
|
||||||
if (val.length < 6) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
Reference in New Issue
Block a user