JavaScript to give error on pushing a duplicate value in an array
var fileArray= [];
var file1=attachment[0].files[0].val();
//somewhere else
function insertUniqueAttachment(file1){
if(!fileArray.includes(file1)){
fileArray.push(val)
}else{
alert("can't contain duplicate value");
}
}
if(!fileArray.includes(file1)){
fileArray.push(val)
}else{
alert("can't contain duplicate value");
}
}
Comments
Post a Comment