sharepoint 验证自定义字段
我在 sharepoint 中创建了一个自定义列表(创建并配置到 12 个配置单元),
当添加新列表项时,如何对列表的某些字段执行验证?
我想我可以通过“itemadding”事件接收器来做到这一点,但是有没有更优雅的共享点方式?
例如,我只想检查电子邮件字段是否具有有效的电子邮件格式。
I cave created a custom list in sharepoint (created and provisioned to the 12 hive)
how can i perform validation on certain fields of the list when a new list item is added?
i think i can do it through the "itemadding" event reciever, but is there a more elegant sharepoint way?
eg i just want to check an email field has a valid email format.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为你必须做出选择。 正如您已经提到的,使用事件接收器是一种方法。 但我认为更优雅、最重要的是更像 SharePoint 的方式是实现您自己的 自定义字段类型和字段控制。
这将使您可以选择在触发任何事件接收器之前验证邮件地址,并通过验证消息向用户做出反应,让他可以选择更正其输入。
I think you have to options. As you have already mentioned using a event receiver would be one way. But I think a more elegant and above all a more SharePoint like way would be implementing your own custom field type and field control.
This will give you the option to validate the mail address before any event receiver is triggered and to react with an validation message to the user giving him the option to correct his input.
如果您在电子邮件输入的渲染文本框中有 id 或 css 类,则可以使用 JQuery 在客户端上进行验证。
You could go with validation on the client using JQuery if you have the id or a css class on the rendered textbox for the email input.