编写约束以根据 Orbeon Form Builder 中另一个字段中输入的值验证字段

发布于 2024-11-15 14:06:31 字数 140 浏览 3 评论 0原文

我想根据“电话类型”字段中所做的选择来验证电话号码字段的大小。手机号码的大小应为 10,家庭和工作号码的大小应为 11。我将如何在 Orbeon Form Builder 中编写约束表达式。我尝试在约束字段中使用 if ,但没有成功。

感谢您的帮助!

I want to validate the size of the phone number field based on the selection made in the Phone Type field. Cell numbers should be 10 in size, Home and work numbers should be 11 in size. How would I write the constraint expression in Orbeon Form Builder. I tried using if in the constraint field, but was unsuccessful.

Thank you for your help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

懵少女 2024-11-22 14:06:31

假设您有两个控件:电话类型和电话号码。

  1. 创建电话类型控件,例如作为下拉列表或单选按钮。为其命名,单击齿轮打开编辑控件详细信息。假设该名称是电话类型。稍后您将把用户选择的值称为 $phone-type
  2. 编辑项目并记住您分配给每个项目的值。该值是您稍后将使用的内容,而标签是在表单中向最终用户显示的内容。假设值为 workmobile
  3. 创建一个单行控件(文本字段),单击红色感叹号打开“编辑验证属性”对话框,然后在“约束”下写入:< /p>

    string-length(.) = (if ($phone-type = 'work') then 11 else 10)

Let's say you have two controls: a phone type and a phone number.

  1. Create the phone type control, for instance as a drop-down or radio buttons. Give it a name, clicking on the cogwheel to open Edit Control Details. Say that name is phone-type. You will will refer later to the value selected by users as $phone-type.
  2. Edit the items and keep in mind the value you assign to each item. The value is what you will use later, while the label is what is displayed to end users in the form. Say the values are work and mobile.
  3. Create a single line control (text field), click on the red exclamation mark to open the Edit Validation Properties dialog, and there, under Constraint, write:

    string-length(.) = (if ($phone-type = 'work') then 11 else 10)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文