views:

66

answers:

1

Hello all,

I have two textboxes, each contain a time (textboxA / textboxB). I need to be able to validate that textboxA is before textboxB.

For exmaple:

  • textboxA = 10:30 / textboxB = 12:30 VALIDATION = true
  • textboxA = 10:30 / textboxB = 10:00 VALIDATION = false

I would prefer to do the checks using server-side controls.

Thanks in advance for any help.

Clare

+5  A: 

You'll want to use the CompareValidator for that and since .NETs drag & drop validators provide both client-side and server-side validation you're covered.

You'll also want to check the Page.IsValid property before processing server side to verify that all the validation was successful.

Gavin Miller
The CompareValidator is a good suggestion, but the validators do NOT do client side validation only. Validation is done on both the client AND the server by default. You can override this so that it is ONLY server-side, but you would actually ave to override the ServerValidate event to get i to NOT validate on the server.
David Stratton
It's too bad you can't give an up AND a down vote. grr.. Because the rest of your answer is good enough I would have voted it up.
David Stratton
@David - Thanks I didn't actually know that; Corrected my answer to reflect that.
Gavin Miller
I'm actually trying to undo my down vote but it's not working. Sorry.
David Stratton
@David - very true. I blame the fact that the server-side validation code is not immediately transparent when you use validators that may lead one to believe they are client-side only.
Russ Cam
Thanks LFSR / David. Ill look into CompareValidator.
ClareBear