开发者

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

开发者 https://www.devze.com 2023-03-12 23:12 出处:网络
I want to validate the size of the phone number field based on the selection made in t开发者_JS百科he Phone Type field. Cell numbers should be 10 in size, Home and work numbers should be 11 in size. H

I want to validate the size of the phone number field based on the selection made in t开发者_JS百科he 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!


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)

0

精彩评论

暂无评论...
验证码 换一张
取 消