You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Joose Vettenranta <jo...@iki.fi> on 2004/11/25 07:24:03 UTC

cforms javascript validation

Hello,

when form is loaded and data inputted in valid way -> OK
when form is loaded and phone or email field is left missing -> comes a 
failure page OK
when only phone is entered -> comes a failure page ERROR
when only email is enetered -> validates OK
when both are defined -> validates OK

so why does that phone thingie get's an error? I put +phone to 
errormessage and it showed null. So why it doesn't refresh it's values?


I have like this:

<fd:form ...>
  <fd:validation>
   <fd:javascript>
          var email = widget.lookupWidget("email");
          var phone = widget.lookupWidget("phone");
          var success = true;

          if (email.value == null &amp;&amp; phone.value == null) {
                 email.setValidationError(new 
Packages.org.apache.cocoon.forms.validation.ValidationError("Email or 
phonenumber missing!", false));
                 success = false;
          }

         return success;
   </fd:javascript>
  </fd:validation>
  <fd:widgets>
     <fd:field id="email" required="false">
       <fd:datatype base="string">
        <fd:validation>
         <fd:email/>
        </fd:validation>
       </fd:datatype>
       <fd:label>Email</fd:label>
     </fd:field>

     <fd:field id="phone" required="false">
       <fd:label>Phone</fd:label>
       <fd:datatype base="string"/>
       <fd:validation>
         <fd:length min="2"/>
       </fd:validation>
     </fd:field>
  </fd:widgets>
</fd:form>

Thanks,

Joose

--
"Always remember that you are unique, just like everyone else!"
* http://iki.fi/joose/ * joose@iki.fi * +358 44 561 0270 *


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org