Hi people.
I am attempting to determine how best to prevent a users date entry in an
update action from causing a format exception. The dates are UK, but the
user may try to put in a 'US' format.
I have a datasource which is wired to my DAL/update function.
1.) On the server side.
Where do I need to check this ?
2.) On the client side.
If I wanted to set up JSCRIPT validation, whats the best way to acheive this
?
I dont neccesarilly need fine detail, but a broad brush roadmap of what to
do and Ill work it out from there.
Thanks. !
Just Me - 21 Mar 2008 21:23 GMT
Ahh, dont worry. Ive found a way.
Basic Steps to enable this of client side ( Per Text Input ) is this.
1.) Handle GridView1_RowDataBound
2.) Find and cast the required textbox to a textbox.
3.) Add an attribute("onkeypress","yourDateFormatValidationFunction");
I still need to validate on the server that the actual date exists, but
thats not going to be too troublesome.
Cheers
> Hi people.
>
[quoted text clipped - 17 lines]
>
> Thanks. !
Stan - 21 Mar 2008 22:10 GMT
> Hi people.
>
[quoted text clipped - 17 lines]
>
> Thanks. !
Hi
Use a CompareValidator control for a client-side check prior to
postback. Set the 'operator' (properties window) property to
DataTypeCheck. You can use this in conjunction with a RangeValidator
to filter on the required period if applicable.
Unfortunately there is no way to guarantee day/month v month/day
ambiguity for text input. Most web sites that require date input use
drop-down lists for day and month instead.
Alternatively use the ASP.NET calendar control. They require more
space on the page and can generate a lot of round trips during the
selection process but are user friendly and easy to work with on the
development side.
HTH