Cool. Thanks for the help Jasha!
Jun

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Jasha
Joachimsthal
Sent: Monday, March 23, 2009 12:11 AM
To: Hippo CMS development public mailinglist
Subject: Re: [HippoCMS-dev] Template validation: at least one field
required?

2009/3/20 <[email protected]>

> Hi guys,
>
> I am trying to create a template validation rule like this: "at least
> one of the three fields is required".
>
> Is that possible?
>
> Yes with flowscript it's possible. Something like

<rule for="/document//foo">

    <validation>
      <validator name="javascript">
        <![CDATA[
        var barWidget = lookupWidget(widget,"/root/bar");
        if (barWidget != false){
          if ((barWidget.value == null || barWidget.value.length()<=0)
&&
(widget.value == null || widget.value.length() <= 0)){
            setValidationError(widget,"Fill in at least one of the
fields.");
            return false;
          }
        }
        clearValidationError(widget); // clear previous validation
errors
        return true;
      ]]>
      </validator>
    </validation>
  </rule>


-- 
Jasha Joachimsthal

[email protected] - [email protected]

www.onehippo.com
Amsterdam - Hippo B.V. Oosteinde 11 1017 WT Amsterdam +31(0)20-5224466
San Francisco - Hippo USA Inc. 101 H Street, suite Q Petaluma CA
94952-5100
+1 (707) 773-4646
********************************************
Hippocms-dev: Hippo CMS development public mailinglist

Searchable archives can be found at:
MarkMail: http://hippocms-dev.markmail.org
Nabble: http://www.nabble.com/Hippo-CMS-f26633.html


********************************************
Hippocms-dev: Hippo CMS development public mailinglist

Searchable archives can be found at:
MarkMail: http://hippocms-dev.markmail.org
Nabble: http://www.nabble.com/Hippo-CMS-f26633.html

Reply via email to