Date validation problem: from endless loops to javascript problems
I am figuring out this problem in my head which is a good reason to write it in a post on my blog. I have this control which is a date control, that is used in different usercontrols on an internet page or a Sharepoint page. The control exists of an Ajax control toolkit datecontrol. When the customer on the page wants to save the page the date must be valid of course. Another important thing is that my page exists of a presentation part en there is a presentation model. In this presentation model there is a possibility for custom validation. Seems easy doesn’t it? But…. Here are possibilities and thoughts:
1. I cannot use the custom validation to check if the date is valid. Because when I type in an invalid date, then by the time it gets to the presentation model the date is empty, so I cannot distinguish between an invalid date and an empty date. In this form it is possible to enter no date at all. I tried to think of a way to make sure the date is not empty when it is invalid, but this takes up too much of my time.
2. I used a maskededit extender of the Ajax control toolkit with a validator and entered a validation group on the textbox, the extender and the button. This makes sure the form is not posted when an invalid date is entered. But…although this works fine, there are two problems. What if you do not want a validation group on the save button? The second problem is severe. Because there are some date controls which trigger a postback. When a masked extender is used on these controls the postback triggers an endless loop. There is an issue about this in the issue tracker of the Ajax control toolkit. Feel free to vote.
3. You could think of a way with Javascript to make script so the user cannot leave the date box until a valid date is entered and the user can leave when it is empty. This is not really user friendly. But is it possible? Well this is really hard. I could make a script which takes care of not leaving the textbox to other textboxes. But you can still click on the Save button or checkboxes that are on the form. It seems that you have to overwrite them. This takes up a lot of work.
4. The best option seems to disable the textbox and make sure the user can only select a valid date. Any other checks, like a date cannot be in the future can be checked through custom validation. But is this really user friendly?
So if anyone has suggestions feel free to comment. I will give it some more thought and when I have an answer I will post it.
4 comments »
Copy link for RSS feed for comments on this post or for TrackBack URI
Leave a comment
Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
Buy:Nexium.Mega Hoodia.Prevacid.100% Pure Okinawan Coral Calcium.Prednisolone.Retin-A.Arimidex.Synthroid.Actos.Zyban.Zovirax.Accutane.Lumigan.Valtrex.Petcam (Metacam) Oral Suspension.Human Growth Hormone….
Trackback by ALBERTO — July 20, 2010 @ 12:37 pm
Buy:Aricept.Lipothin.Lipitor.Female Cialis.Advair.SleepWell.Cozaar.Zocor.Buspar.Nymphomax.Wellbutrin SR.Ventolin.Prozac.Seroquel.Lasix.Amoxicillin.Acomplia.Zetia.Female Pink Viagra.Benicar….
Trackback by DARRYL — July 22, 2010 @ 1:30 am
trucks http://nfoldjvi8hpl.copious-systems.com/tag/trucks+cup+holder/ : cup…
cup…
Trackback by trucks — August 30, 2010 @ 10:11 am
Buy:Soma.Tramadol.Viagra Professional.Viagra.Viagra Super Force.Viagra Super Active+.Cialis Super Active+.Cialis Soft Tabs.Super Active ED Pack.VPXL.Levitra.Cialis Professional.Propecia.Zithromax.Viagra Soft Tabs.Cialis.Maxaman….
Trackback by RAMON — September 5, 2010 @ 12:09 am