I have seen similar issues on this site but I can't get this to work. I am trying to detect duplicate entries in input boxes through Javascript - but I want the loop to break when a duplicate is entered. I have that part working, but the loop continues to run and it creates an infinite loop that the user can't get out of. I am trying to break the loop and have the user re-enter a different value.
function checkDuplicates() {
var numFlds = <cfoutput>#form.UnitCount#</cfoutput>;
for (var x=1; x<=numFlds; x++) {
for (var y=x+1; y<=numFlds; y++) {
if (document.getElementById('SN'+y).value !== '')
if (document.getElementById('SN'+x).value == document.getElementById('SN'+y).value) {
alert('Duplicate Serial Number Entered!');
break;
}
}
}
}