Skip to content

Commit

Permalink
modified web form
Browse files Browse the repository at this point in the history
  • Loading branch information
maa17019 committed Mar 22, 2021
1 parent 335291c commit 4515331
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 1 deletion.
Binary file modified week-9/working-web-form/.DS_Store
Binary file not shown.
Binary file added week-9/working-web-form/fav/.DS_Store
Binary file not shown.
Binary file added week-9/working-web-form/fav/favicon-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added week-9/working-web-form/fav/favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 6 additions & 1 deletion week-9/working-web-form/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Web Form That Works</title>
<!-- Place favicon.ico in the root directory -->
<link rel="icon" type="image/png" href="fav/favicon-16x16.png">
<link rel="apple-touch-icon" href="fav/favicon-32x32.png">

<link href="css/form.css" rel="stylesheet">

</head>
<body>

<form action="https://formspree.io/f/mdoynapr" method="POST">

<h1>Web form that works!</h1>
<h1>Web form that works &#128512;</h1>
<h4>*Fill in all fields</h2>
<p>
<label for="name"><span>Name:* </span></label> <!--Name-->
Expand Down
6 changes: 6 additions & 0 deletions week-9/working-web-form/js/main.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/*Retrieve form attributes*/
let forms = document.querySelector("form");
let namee = document.getElementById("name");
let mail = document.getElementById("mail");
Expand All @@ -13,6 +14,7 @@ let warning = document.querySelector("#warning");
message.value === ""
];*/

/*Event listener for if no fields are filled in*/
forms.addEventListener("submit", function (event) {
if ((namee.value === "" || mail.value === "") && (subject.value === "" || message.value === "")){
event.preventDefault();
Expand All @@ -22,21 +24,25 @@ forms.addEventListener("submit", function (event) {
subject.style.borderColor = "red";
message.style.borderColor = "red";
}
/*If NAME field is not filled in*/
else if (namee.value === "") {
event.preventDefault();
warning.innerHTML = "You must fill in the NAME field!" ;
//form.style.borderColor = "red";
namee.style.borderColor = "red";
/*If EMAIL field is not filled in*/
} else if (mail.value === "") {
event.preventDefault();
warning.innerHTML = "You must fill in the EMAIL field!";
//form.style.borderColor = "red";
mail.style.borderColor = "red";
/*If SUBJECT field is not filled in*/
} else if (subject.value === "") {
event.preventDefault();
warning.innerHTML = "You must fill in the SUBJECT field!";
//form.style.borderColor = "red";
subject.style.borderColor = "red";
/*If MESSAGE field is not filled in*/
} else if (message.value === "") {
event.preventDefault();
warning.innerHTML = "You must fill in the MESSAGE field!";
Expand Down

0 comments on commit 4515331

Please sign in to comment.