New to using regex vcustom validation | XM Community
Skip to main content

Hi all-

 

New to useing regex here and have read through quite a few of the forums on regex, however the use cases I’m seeing people use are only getting me about halfway to the validation I’m trying to add. I am trying to add validation so that the text needs to alwasy start with “ClassID” and end in a date format with no “/” or spaces, ie “ClassID083123”. Any help would be appreciated.

 

Thank you

@wcunningham You can use this

^ClassID(001-9]|110-2])(001-9]||12]\d|3301])(\d{2})$
 

Note: This only give you a number entry validation, it does not take into account leap years or month-specific day limits. If you need more accurate date validation, you might need to consider additional logic beyond regex.


@wcunningham,

You could hide the text input and create your own input, and use cleave.js to make sure a valid date is entered. HTML would be something like:

ClassID<input id="classIdDate" type="text">

Then use the concatenation of ClassID and the date to set the value of the hidden input.

For validation,  you only need to check that the length of the input is 13. 


Leave a Reply