Validating MM/YY field for format and that only accepts 1-12 for MM | XM Community
Skip to main content
I would like to create a custom validation regex code that means that participants have to enter a date in the format (MM/YY). I would also like them to have to enter 01-12 for the MM section (to make sure they enter month, not day). Is this possible? Any help would be great 😀
Hi @miki,

definitely yes. Have you tried Google? I'm sure you aren't the first one who wants to implement something like this.
Hi,

Thanks for your reply - I have, I've searched all over and couldn't find anything! It is okay though I have just gone for something similar 🙂
OK,

I'm sorry then. I found one which does what you want together with the validation of a valid day and year in a few seconds. I have just shortened it: `^([0-2][0-9]|(3)[0-1])(\\/)(((0)[0-9])|((1)[0-2]))$`



If you don't want validation of valid days, it would look like this: `^\\d{2}(\\/)(((0)[0-9])|((1)[0-2]))$` or like this: `^\\d{1,2}(\\/)(((0)[0-9])|((1)[0-2]))$`



It would be nice if you would post your own answers here and accept them in case you don't need help any more.

Leave a Reply