Form data is now parsed

This commit is contained in:
eoghan.conlon 2023-08-08 18:48:22 +01:00
parent f42355c4a1
commit 62c0767e78

View file

@ -26,7 +26,20 @@
function formHandler(listener){ function formHandler(listener){
listener.preventDefault(); listener.preventDefault();
alert('Not implemented yet'); const option = document.getElementById('options').value.toString();
if(option === ''){
alert("Need to implement this");
} else {
const formData = new FormData(formEl);
const value = formData.get('value');
let object;
if (option === 'email'){
object = { email: value };
} else {
object = { user: value };
}
alert(JSON.stringify(object));
}
} }
function selectField(){ function selectField(){