I have a submission page with validations to ensure all areas of the form are correctly submitted. There is a section of the submission form where the user must enter a correct case number. If entered correctly (checks a text file), the name of a debtor appears (in the debtor field). If they enter a case number incorrectly or enter random numbers, they will receive a "CASE NUMBER NOT FOUND" in place of the debtor name. The minimum number of characters required in the case number field is 10. If they enter 10 numbers/characters regardless if it is valid or not, they are able to continue. I do not want this to happen.
What I want the validation to do with the case number
1. Ensure a case number's format is entered correctly - 8:09-bk-00234? (If Possible)
2. Make sure at least 10 numbers are entered
What I want the validation to do with the debtor
1. If debtor field is blank, do not allow to submit
2. If debtor field returns CASE NUMBER NOT FOUND, do not allow to submit
Below is a snippet of the validation that currently works, but obviously needs tweaking.
Any assistance with code is GREATLY appreciated. Thank you!
if (theForm.case_number.value == "")
alert("Please enter your full case number in the \"Case Number\" field");
if (theForm.case_number.value.length < 10)
alert("Please enter at least ten characters in the \"Case Number\" field");
if (theForm.debtor.value == "")
alert("Debtor information is invalid. Please enter the correct Case Number in the \"Case Number\" field");