You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by 32...@gmail.com on 2006/07/11 14:37:52 UTC

captcha validation & fd:failmessage

Hello,

my aim is to use captcha validation on forms, including a custom
failmessage.
My try was like that:


<fd:captcha id="capt" required="true" length="5">
      <fd:help>case sensitive!</fd:help>
      <fd:datatype base="string"/>
      <fd:validation>
        <fd:captcha>
            <fd:failmessage>Wrong! Try again</fd:failmessage>
        </fd:captcha>
      </fd:validation>
</fd:captcha>


but the displayed error message still is "validation.captcha.mismatch"
Whats my mistake?

Thanks for your help
Marco

Re: captcha validation & fd:failmessage

Posted by 32...@gmail.com.
Hi Andrew,

thank you very much for your answer. I solved the issue in the meantime via
i18n Transformer.
Thanks again for your help
Marco



2006/7/11, Andrew Madu <an...@gmail.com>:
>
> Hi Marco,
> I do the same but using flowscript like so:
>
>     <fd:validation>
>         <fd:javascript>
>             var success = true;
>             var captcha_code = widget.lookupWidget("captcha_code");
>             var captcha_generated = cocoon.session.getAttribute
> ("captcha");
>             var parameters = {"supplied": captcha_code.value, "expected":
> captcha_generated};
>
>             try {
>
>                    if
> (parameters['supplied'].equals(parameters['expected'])) {
>                         cocoon.session.setAttribute("user",
> checkUserTest);
>                     } else {
>                         captcha_code.setValidationError(new
> Packages.org.apache.cocoon.forms.validation.ValidationError("The string
> you entered is incorrect. Please re-enter.", false));
>                         success = false;
>                     }
>
>
> HTH
>
> Andrew
>
>
>
> On 11/07/06, 321los@gmail.com < 321los@gmail.com> wrote:
> >
> > Hello,
> >
> > my aim is to use captcha validation on forms, including a custom
> > failmessage.
> > My try was like that:
> >
> >
> > <fd:captcha id="capt" required="true" length="5">
> >       <fd:help>case sensitive!</fd:help>
> >       <fd:datatype base="string"/>
> >       <fd:validation>
> >         <fd:captcha>
> >             <fd:failmessage>Wrong! Try again</fd:failmessage>
> >         </fd:captcha>
> >       </fd:validation>
> > </fd:captcha>
> >
> >
> > but the displayed error message still is "validation.captcha.mismatch"
> > Whats my mistake?
> >
> > Thanks for your help
> > Marco
> >
> >
>

Re: captcha validation & fd:failmessage

Posted by Andrew Madu <an...@gmail.com>.
Hi Marco,
I do the same but using flowscript like so:

    <fd:validation>
        <fd:javascript>
            var success = true;
            var captcha_code = widget.lookupWidget("captcha_code");
            var captcha_generated = cocoon.session.getAttribute("captcha");
            var parameters = {"supplied": captcha_code.value, "expected":
captcha_generated};

            try {

                   if
(parameters['supplied'].equals(parameters['expected'])) {
                        cocoon.session.setAttribute("user", checkUserTest);
                    } else {
                        captcha_code.setValidationError(new
Packages.org.apache.cocoon.forms.validation.ValidationError("The string you
entered is incorrect. Please re-enter.", false));
                        success = false;
                    }


HTH

Andrew


On 11/07/06, 321los@gmail.com <32...@gmail.com> wrote:
>
> Hello,
>
> my aim is to use captcha validation on forms, including a custom
> failmessage.
> My try was like that:
>
>
> <fd:captcha id="capt" required="true" length="5">
>       <fd:help>case sensitive!</fd:help>
>       <fd:datatype base="string"/>
>       <fd:validation>
>         <fd:captcha>
>             <fd:failmessage>Wrong! Try again</fd:failmessage>
>         </fd:captcha>
>       </fd:validation>
> </fd:captcha>
>
>
> but the displayed error message still is "validation.captcha.mismatch"
> Whats my mistake?
>
> Thanks for your help
> Marco
>
>