简体   繁体   English

Sitecore验证

[英]Sitecore Validation

This seems like a really simple task to accomplish, but I can't seem to figure it out. 这似乎是一项非常简单的任务,但我似乎无法弄明白。 How do you assign validation to a particular field in Sitecore? 如何为Sitecore中的特定字段分配验证?

I can see the validation rules listed in /sitecore/system/Settings/Validation Rules/Field Rules/ . 我可以在/sitecore/system/Settings/Validation Rules/Field Rules/看到验证规则。

How do I assign a rule from here to a field on a template? 如何从此处将规则分配给模板上的字段?

I've seen several blog posts about creating a custom OnSave action that evaluations the item and it's fields - that you then hook up in the web config - but that is way overkill for what I'm trying to accomplish. 我已经看过几篇关于创建自定义OnSave操作的博客文章,该操作评估项目及其字段 - 然后您将其连接到Web配置中 - 但这对我正在尝试完成的事情来说太过分了。 None of the blog posts or pdfs from Sitecore itself seem to show how to set up really simple validation (or I can't find them). Sitecore本身的博客文章或pdf都没有显示如何设置真正简单的验证(或者我找不到它们)。

对于某些基本验证,您可以浏览到您的模板,选择字段本身(模板下面的字段项,我的意思是)并浏览到验证规则部分。

There is also another simple way (did not check if it stil exists in Sitecore 7). 还有另一种简单的方法(没有检查它是否存在于Sitecore 7中)。 Go to the template field itself, as Trayek says, and therer you have 2 fields: "Validation" and "ValidationText". 转到模板字段本身,正如Trayek所说,并且你有2个字段:“Validation”和“ValidationText”。 In Validation you enter the regex for the validation and in ValidationText you enter the text to display. 在验证中,输入验证的正则表达式,在ValidationText中输入要显示的文本。

在此输入图像描述

Just set validation rule Item id in Suppressed Validation Rules field. 只需在“ 禁止验证规则”字段中设置验证规则项目ID。

在此输入图像描述

首先检查顶部功能区“视图”选项卡中的“标准字段”复选框,然后选择所选项目的数据模板,选择要验证的字段,在此字段中可以找到验证规则栏,您可以在此处应用验证。

I would not just dump a regex in the validation field. 我不会在验证字段中转储正则表达式。 Creating a rule and assigning it on a template affords you a lot more flexability 创建规则并在模板上分配规则可以提供更多灵活性

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM