Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #15 from lmc15106/feature/formvalidation
form validation for real this time
  • Loading branch information
lmc15106 committed Nov 13, 2019
2 parents 50be61a + 2fa5c19 commit fd0195e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions js/main.js
Expand Up @@ -12,11 +12,16 @@ const form = document.querySelector('#my-form');
//saving data
form.addEventListener('submit', (e) => {
e.preventDefault();
if (form.input.value.trim() == '' && form.input2.value.trim() == ''){
console.log('empty');
}else{
db.collection('questions').add({
question: form.input.value.trim(),
answer: form.input2.value.trim(),
timestamp: new Date()
});
}

//reset the form
form.input.value = "";
form.input2.value = "";
Expand Down

0 comments on commit fd0195e

Please sign in to comment.