Hi @anamikadutt,
Welcome to the community! You could do the same by using constraint and constraint_message as outlined in the image below:
In the survey tab of the xlsform:
Reference xlsform:
Roll Number (constraint).xlsx (10.4 KB)
HAVE a GREAT DAY!

