Form validation with Ajax

I have started an FAQ article in the CakePHP Wiki about form validation with Ajax. With a simple example I show how to display messages depending on the text you enter, and how to submit your form only when all input fields are filled out correctly. Feedback is welcome!



  1. Posted August 13, 2006 at 5:36 am | Permalink

    Hey, I copied your post (almost exaclty). It looks like it could work great, except that everytime the function ajaxValidateUsername is called in the controller, it causes my default layout to render inside the div instead of just labelText. I’ve added $this->layout = “ajax”; but it doesn’t do any good. Any ideas what i need to change in order to get it to just print the message in labelText?


  2. Posted August 13, 2006 at 8:28 am | Permalink

    Hm, have you tried $this->render(‘viewname’, ‘ajax’); ? Or the RequestHandler component: $this->RequestHandler->setAjax($this);


Post a Comment

Required fields are marked *

%d bloggers like this: