About using logic

You could do the same as outlined in the image shared below:

In the survey tab of your xlsform:

Data entry screen as seen in Enketo: (when a wrong entry is made)

Data entry screen as seen in Enketo: (when a correct entry is made)

Reference xlsform:

Bank.xlsx (10.4 KB)