mardi 4 août 2015

How to have multiple regex for same element

I have a text box which has a regular expression which is something like below

^AB[a-zA-Z0-9]{20}$

which basically allows charecter AB , followed by 20 either alphabetic or numbers, and for example lets consider the validation error for not following this regex is Some Test Error

I have a scenario where user enters AB1234 and tabs out of the text box, and the error Some Test Error shows, but I have a requirement of not showing the same error message Some Test Error if user is trying to follow the format but not adhering to the entire regex.

Scenario 1 :- User enters CD12345675438976524381 I need to show Some Test Error

Scenario 2 : USer enters AB12345 I need to shoe Different Test Error, because user tried to enter a value starting from AB*

How can achieve this, is there a way of specifying multiple regex's?

Aucun commentaire:

Enregistrer un commentaire