jformvalidate + captcha = got some problem

Hi Guys,

Need some help.

Got some problem, I have a page now called it User Registration, what I did was, I use dthe JFormValidate extension to be able to validate the users input in local machine rather that server side. This could avoid to used the server processor, since we can used the client side processor using the extension. I got it correctly to validate the users input data, but got some problem when I try to get a new code for captcha, it doesn’t work at all!

regards,

Pinoy Coderz

Hi,

could you please provide more detail on the error that you had ? When you say “it doesn’t work at all” do you mean that client -side validation is not triggered ? is there some ajavscript error ? Maybe you could post the code of your form and model so I can have a look at it ?

bye

8)

Hi Pinoy Coderz,

the problem you have is that the CCaptcha widget creates input elements using the CHtml helper provided by Yii, and not the EHtml helper that should be used to enable client side validation … therefore, no JS validation occurs.

To make it simple, let’s say that each time you create a form field using EHtml, the jformvalidate extension retrieve its associated validation rule, and at the end of the form, it uses all rules collected to initialize the Jquery Validate plugin who is in charge of client side validation. In this case, CCaptcha create the input text using CHtml, so the jformvalidate extension is not aware that this field should be client side validated…

On the other hand, I don’t really understand why you need client-side validation for captcha, when by design, captcha validation must occurs on server side… I guess the only rule you want to test is ‘required’ right ? In this case I’m sorry, but there is no way currently to make it work like you want …(unles you overload the CCaptcha Widget and replace CHtml with EHtml … but this needs testing ;) )

ciao

8)