编写约束以根据在 Orbeon 表单生成器中的另一个字段中输入的值来验证一个字段 [英] Write constraint to validate a field based on the value entered in another field in Orbeon Form Builder

查看:62
本文介绍了编写约束以根据在 Orbeon 表单生成器中的另一个字段中输入的值来验证一个字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想根据电话类型字段中的选择来验证电话号码字段的大小.单元格编号应为 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.

感谢您的帮助!

推荐答案

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

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

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

  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)

这篇关于编写约束以根据在 Orbeon 表单生成器中的另一个字段中输入的值来验证一个字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆