Hello experts:
My form keeps ignoring the preventDefault JS event.
I built an html form with JS backend connected. The form is supposed to write to a Firebase db. The db is already active and works with an Android app. Permissions for testing are set to true for write and read.
I built the JS file incrementally testing code with the console log along the way. It worked perfectly till the Firebase script was added. Now it ignores the event to preventDefault.
The console lists no exceptions.
The site is https://www.hrmualpha.com.
I have looked and looked at this till my eyes are falling out of my head. Can you spot what I'm missing?
Thanks.
// Create Reference Collection var testvaluesRef = firebase.database().ref('testvalues');// Listen for form submitdocument.getElementById('contactForm').addEventListener('submit', submitForm);// Submit formfunction submitForm(e){ e.preventDefault();console.log(123); // Get values var name = getInputVal('name'); var email = getInputVal('email'); var phone = getInputVal('phone'); var allvalues = name + ", " + email + ", " + phone; console.log(allvalues); // Save values to Firebase saveTestValues(name, email, phone);// Function to get get form valuesfunction getInputVal(id){ return document.getElementById(id).value;}}// Save values to firebasefunction saveTestValues(name, email, phone){ var newtestvaluesRef = testvaluesRef.push(); newTestvaluesRef.set({ name: name, email:email, phone:phone }) console.log(newTestvaluesRef);}
Thanks. I can't believe how many times I looked at that and missed it.