Programmation xlsform

how I can put a constraint to link two fields with the same data example: mail 1: and we ask a person to repeat if mail 2 is different from mail1 you cannot go to the next screen

If you have two questions and you need to make sure the answers are equal you can add something like (to the row with mail2):
. = ${mail1}

What if I want to limit a field to only 4 digits

There is string-length function: