views:

710

answers:

2

I am creating two columns Start and end date, when the user enters end date I should validate it with the start date to check that its greater than start date, is there a way to do that?? I am using Custom Library for this, My requirement is I have to store a document with start and end date and I need to do some validations on it.

Thanks for the help

+5  A: 

If you need the validation in the UI I would go with a custom field type.

If you need the the check upon creation in the library I would go with an eventreceiver and ItemUpdating/ItemAdding events.

Or maybe a combination...

If this is what you want, let me know and I´ll provide some code examples for you (if you need that).

UPDATE:

If you need an example of a custom field type see this post. You could in fact combine that with some JQuery if you for example add a special css class to the rendered control and then add you JQuery to validate it client side.

I don´t know if you need an example of an event reciever or how to add one, but here´s one link for you anyways:

Add eventreceiver extension method example

Johan Leino
It will be great to take a look to the examples, can you email them o how do I contact you?
YeomansLeo
+3  A: 

Custom field type would seem to be overkill (for the UI validation at least.) I'd use JQuery for that, and then follow Johan's recommendation of an eventreciever to validate serverside.

edit: I can string together JQuery to validate the fields if you need.

Jason Watts
It will be great also to have a JQuery alternative, how do I implement it?
YeomansLeo