Allende wrote this for me in answer to an earlier question and I'm trying to figure out how I add an extra piece of code, so that if the user enters a number higher than the total number of records, it throws up an error. I know I can use SQL RecordCount
to find the number of records, but I have no idea how to integrate it into Allende's script. As with the script, the error doesn't need to show until the form is submitted.
$(document).ready(function(){
$('form').on("submit",function(){
var tempArray=[];
var exists=0;
$("input[type='text'][name^='PositionNumber']").each(function(){
exists = tempArray.indexOf($(this).val());
if (exists>=0){
return false;//break the loop
}
tempArray.push($(this).val());
});
//after you can use "exist" to check if duplicated and retrieve the value to cancel the submit
if (exists>=0){
alert("You have used the number " + tempArray[exists] +" more than once.\r\nPlease correct the error and resubmit.");
} else{
//alert("no duplicated value:");
return true;
}
return false;
});
});
Thanks in advance for the help and advice.
Regards
Pb