Skip to content

Commit

Permalink
Check if all input fields are filled out
Browse files Browse the repository at this point in the history
  • Loading branch information
helenclx committed Jan 27, 2024
1 parent d0eba12 commit 33df2b6
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions m3-we-are-the-champions/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,18 @@ formEl.addEventListener('submit', (e) => {
});

const addEndorsement = () => {
endorsementObj = {
...endorsementObj,
from: fromInputEl.value,
to: toInputEl.value,
message: msgInputEl.value
if (msgInputEl.value === '' || fromInputEl.value === '' || toInputEl.value === '') {
alert('Please fill out all input fields before publishing');
} else {
endorsementObj = {
...endorsementObj,
from: fromInputEl.value,
to: toInputEl.value,
message: msgInputEl.value
}
console.log(endorsementObj);
push(endorsementsInDB, endorsementObj);
}
console.log(endorsementObj);
push(endorsementsInDB, endorsementObj);
};

const clearInputEl = () => {
Expand Down

0 comments on commit 33df2b6

Please sign in to comment.