Validating Dates In GridView

J

Just Me

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. !
 
J

Just Me

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
 
S

Stan

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. !

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top