Is there a way to prevent duplicate values from being submitted in my simple site? Currently, I have implemented a function that allows users to input a name and a mark. However, if the same values (name & mark) are entered, I want to notify the user and prevent them from submitting the data again.
function add() {
name.push(nameInput.value);
mark.push(markInput.value);
if (name == "" && mark == "") {
document.getElementById("result").innerHTML = "No name or mark Has Been Entered. Please Try Again!";
} else if (name && mark) {
document.getElementById("result").innerHTML = "Name & Mark has successfully been entered!";
console.log(name, mark);
} else if (name == mark) {
var n = name.includes("Ross", 0);
//console.log(name, mark);//
}
}
document.getElementById("Add").addEventListener("click", insert);