Using onclick and adding an event listener to my button does not correctly call the function.
How can I call my function through a button press in the HTML. I also have jquery added so am able to use jquery syntax aswell.
document.getElementById("fName-group").addEventListener("click", writeFName, false);
function writeFName(fName-group) {
localStorage.setItem('fName-group', fName-group);
var cfmF = confirm("Did you mean to enter: \n" + fName-group + '?');
if (cfmF) {
console.log(fName-group);
window.alert('Success!');
var theEmail1 = localStorage.getItem('fName-group');
document.getElementById("theEmail1").innerHTML = theEmail1;
console.log(theEmail1);
}
else {
window.alert('Please Re-Enter Data');
}
}
<div class="jumbotron">
<h3> Add new email</h3>
<form id="emailInputForm">
<div class="fName-group">
<label>First Name</label>
<input type="text" class="form-control" id="fName_Input" placeholder="Enter candidate
first name ...">
<div class="email-group-append">
<input type="button" id ="fName_But"value="Submit First Name">
<p id="emailOutput"></p>
</div>
fName-groupis not a valid variable name.