自定义列表比较Sharepoint中的日期

时间:2021-12-13 22:51:22

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

谢谢您的帮助

2 个解决方案

#1


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

如果您需要在UI中进行验证,我将使用自定义字段类型。

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

如果您需要在库中创建检查,我将使用eventreceiver和ItemUpdating / ItemAdding事件。

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.

如果您需要自定义字段类型的示例,请参阅此帖子。实际上,如果你为渲染控件添加一个特殊的css类,然后添加JQuery来验证它的客户端,你可以将它与一些JQuery结合起来。

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

添加eventreceiver扩展方法示例

#2


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.

自定义字段类型似乎有点矫枉过正(至少对于UI验证。)我会使用JQuery,然后遵循Johan的eventreciever推荐来验证服务器端。

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

编辑:如果需要,我可以将JQuery串在一起来验证字段。

#1


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

如果您需要在UI中进行验证,我将使用自定义字段类型。

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

如果您需要在库中创建检查,我将使用eventreceiver和ItemUpdating / ItemAdding事件。

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.

如果您需要自定义字段类型的示例,请参阅此帖子。实际上,如果你为渲染控件添加一个特殊的css类,然后添加JQuery来验证它的客户端,你可以将它与一些JQuery结合起来。

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

添加eventreceiver扩展方法示例

#2


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.

自定义字段类型似乎有点矫枉过正(至少对于UI验证。)我会使用JQuery,然后遵循Johan的eventreciever推荐来验证服务器端。

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

编辑:如果需要,我可以将JQuery串在一起来验证字段。