I was about to start coding some validation for date input on a TextField and thought I’d check I’m not missing any useful shortcuts or built-in methods I may have missed before I do.
My dates are stored as SQL DateTime but I want them displayed in UK format. I’m planning on doing this with string manipulation - easy enough.
For input validation I have a mask of “##-##-####” which is fine but I want to check the date is actually valid. So my plan is to have a TextChange event on the text field and when:
first 2 digits entered - make sure it’s 31 or less
first 4 digits entered - check month is 12 or less and then check the day number is valid for that month ( so not 31-11 or 30-02 for example)
all digits entered - check if dd/mm was 29-02 and if so, make sure the year is a leap year
Then convert back to SQL DateTime for storage of course.
Is this all a bit long winded? Any better methods?
Thanks