![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Professional Programmer
Join Date: Jan 2006
Location: Ontario, Canada
Posts: 376
Rep Power: 0
![]() |
I need to make sure that when someone enters a date into the textbox on my form that it is entered in the correct format (“4/30/2006”). I think using a Regular Expression for this would work, but I can’t get anything I found off the net to work properly. I just need to get it working and don’t care how, so any help would be great, thanks.
__________________
I am Addicted to Linux! |
|
|
|
|
|
#2 |
|
Professional Programmer
Join Date: Jan 2006
Location: Ontario, Canada
Posts: 376
Rep Power: 0
![]() |
I fixed it with a different solution. What I did was just try and convert the textbox text to a DateTime, and if it doesn't throw and error the date is fine.
__________________
I am Addicted to Linux! |
|
|
|
|
|
#3 |
|
Hobbyist Programmer
Join Date: Jun 2005
Location: New Mexico
Posts: 228
Rep Power: 4
![]() |
Consider using regexp - C# (All of .NET) supports it. It's far more robust than creating a deliberate error/no error condition - if all you're interested in is correct format.
See: http://regexlib.com/ It's a reference for tested regexes - cook book style. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|