Regular Expression
-
Hi All, I am wondering how to validate date using regular expression and not allowing any future date if the user wants to put it in anyway. thanks,
Hi, no, it's not possible with regular expression, regular expression can only validate patterns, you can use compare validator for this purpose or use .NET function DateTime.Now to acquire todays date, then compare it programmatically with the date from user's input. Regular expression for date is (?x)(?:0[1-9]|1[0-2])(/?)(?:0[1-9]|[12][0-9]|3[01])(\1)\d{4}\d/\d/\d{4}
-
Hi All, I am wondering how to validate date using regular expression and not allowing any future date if the user wants to put it in anyway. thanks,
Just to add to Shahriar Iqbal Chowdhury's answer, you can use the regex validator to do an "idiot check" Client side and use dateTime.TryParse[^] to check server side. There are several attempts to do it here[^] without the regex using JavaScript instead. For the regex pattern, I've always found http://regexlib.com[^] useful, it also gives a summary of how well well the regex matches etc.
Sort of a cross between Lawrence of Arabia and Dilbert.[^]
-Or-
A Dead ringer for Kate Winslett[^] -
Hi, no, it's not possible with regular expression, regular expression can only validate patterns, you can use compare validator for this purpose or use .NET function DateTime.Now to acquire todays date, then compare it programmatically with the date from user's input. Regular expression for date is (?x)(?:0[1-9]|1[0-2])(/?)(?:0[1-9]|[12][0-9]|3[01])(\1)\d{4}\d/\d/\d{4}
-
Hi, no, it's not possible with regular expression, regular expression can only validate patterns, you can use compare validator for this purpose or use .NET function DateTime.Now to acquire todays date, then compare it programmatically with the date from user's input. Regular expression for date is (?x)(?:0[1-9]|1[0-2])(/?)(?:0[1-9]|[12][0-9]|3[01])(\1)\d{4}\d/\d/\d{4}
-
Hi All, I am wondering how to validate date using regular expression and not allowing any future date if the user wants to put it in anyway. thanks,