Client validation issue (have to click submit twice after field error)

[size="4"]Hello people[/size].

[size="3"]There is a form generated by CActiveForm with enableClientValidation set to true.

When i enter wrong value in any field and try submit form i get validation error message from javaScript.

It is all OK, but after that when i correct wrong value i still see error message until i remove focus from that field.

If i try to submit form when cursor is still in that filed nothing happens but just error massage disappears instead of form sending. So i have to submit once again to send.

Is there any way to avoid this behaviour?[/size]

I haven’t played with client validation too much but it sounds like an event (maybe onBlur) is firing - preventing you from submitting the form. Check to see what events are being triggered. Post your code if your still stuck.


Thanks for reply.

It is not some special code that i am working on. It is just standard behaviour out of the box. To see this effect one can just create empty project and go to "contact us" page.

But maybe there is some option that can tune this. If no, so, i will hack into javaScript directly.

I’ve tested it on a blank app and all’s OK - the form submits once all fields are valid. Post your code and I’ll take a look.


Thanks Matt.

I installed a virgin new application to domain [color="#4169E1"][/color] to show the issue.

  1. Go to page [color="#4169E1"][/color]

  2. Fill all fields correctly exept of captcha

  3. Fill incorrect value to captcha field.

  4. Submit form (captcha field becomes red, captcha error message appears)

  5. Change captcha field value to correct.

  6. Do not remove cursor from captcha field.

  7. Submit form with mouse click.

After that i just see captcha field becomes green, error message disappears but no form submission and i have to click submit one more time.

If instead of click submit button i just push enter all goes OK

I think this is already fixed in the trunk… try with the latest Yii code (checkout from googlecode)…

I think mdomba’s correct. I pulled the latest SVN version this morning so I’m not seeing the same issue.

Thanks a lot

Code from [color="#4169E1"][/color] just works great

More than that, if validateOnType option is enabled the whole form revalidates on every keyUp event, that is realy cool.