Write constraint to validate a field based on the value entered in another field in Orbeon Form Builder

匆匆过客 提交于 2019-12-11 05:04:10

问题


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!


回答1:


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)



来源:https://stackoverflow.com/questions/6323506/write-constraint-to-validate-a-field-based-on-the-value-entered-in-another-field

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!