Skip to content

Instantly share code, notes, and snippets.

@Octagon-simon
Last active October 30, 2021 16:40
Show Gist options
  • Select an option

  • Save Octagon-simon/427ce0537f695cd93fa05904b885b6fb to your computer and use it in GitHub Desktop.

Select an option

Save Octagon-simon/427ce0537f695cd93fa05904b885b6fb to your computer and use it in GitHub Desktop.
function saveForm(fname, lname, email) {
//Check form fields
if(!fname){
alert('First Name is required');
}else if(!lname){
alert('Last Name is required');
}else if(!email){
alert('Email Address is required');
}else{
//Check for duplicate records then save
if (fnameArry.includes(fname)){
alert('Duplicate First Name Detected');
}else if(lnameArry.includes(lname)){
alert('Duplicate Last Name Detected');
}else if (emailArry.includes(email)){
alert('Duplicate Email Address Detected');
}else{
//Save form inputs to our Array
fnameArry.push(fname);
lnameArry.push(lname);
emailArry.push(email);
}
//Total Number of records. Since they are equal, choose one array
document.querySelector('#inp_count').innerText = fnameArry.length;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment