Created
October 27, 2021 09:30
-
-
Save Octagon-simon/1229fc1929479625e269471713687af0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment