Ok. I create a simple testpage. Below I wrote all listing from index controller and view files:
IndexController.php: <?php class IndexController extends Zend_Controller_Action { function init() { $this->view->baseUrl = $this->_request->getBaseUrl(); Zend_Loader::loadClass('Users'); } function indexAction(){ $this->view->title = "ZF - Validation"; } function checkloginAction(){ $request = trim(strtolower($_REQUEST['login'])); $valid = 'true'; $users = new Users(); $select = $users->select(); $select->where('login = ?', $request); $usernames = $users->fetchAll($select); foreach($usernames as $username) : if($username->login != ''){ $valid = 'false'; } endforeach; $this->view->valid = $valid; } } index.phtml : <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" media="screen" href="<?php echo $this->baseUrl;?>/public/styles/site.css" /> <script type="text/javascript" src="<?php echo $this->baseUrl;?>/ public/scripts/jquery.js"></script> <script type="text/javascript" src="<?php echo $this->baseUrl;?>/ public/scripts/jquery.validate.js"></script> <title><?php echo $this->escape($this->title); ?></title> </head> <script type="text/javascript"> $(document).ready(function() { // validate signup form on keyup and submit var validator = $("#signupform").validate({ rules: { login: { required: true, minlength: 2, remote: "checklogin" //<-- dosen't work } }, messages: { login: { required: "Enter login", minlength: jQuery.format("Enter at least {0} characters"), remote: jQuery.format("{0} is already in use") } }, // set this class to error-labels to indicate valid fields success: function(label) { // set as text for IE label.html(" ").addClass("checked"); } }); }); </script> <body xml:lang="pl"> <div id="container"> <br /> <form action="sample.php" id="signupform" autocomplete="off" method="post"> <label for="login">Login:</label><br /> <input id="login" type="text" name="login" /> <br /> <br /> <input type="submit" name="signup" value="Register" /> </form> </div> </body> </html> checklogin.phtml : <?php echo $this->valid; ?> Why the remote validation still dosen't work? I don't know what insert into remote function. Please help. David On Oct 16, 5:58 pm, "Jörn Zaefferer" <[EMAIL PROTECTED]> wrote: > Can you post a testpage? > > Jörn > > 2008/10/16 Namrasit <[EMAIL PROTECTED]>: > > > > > Hi! > > > I try to use Zend Framework with JQuery validation plugin. Standard > > validation of forms works good but when I want to remote validate (f.e > > check a login in database) remote function dosen't work. Below I write > > a code with method from controller and views listing: > > > Method from controller: > > > function checkloginAction(){ > > $request = trim(strtolower($_REQUEST['login'])); //take data > > from global REQUEST array > > > $users = new Users(); //make a new class with users > > $select = $users->select(); //select users where > > the login > > $select->where('login = ?', $request); //is the same like from > > REQUEST array > > $login = $users->fetchAll($select); > > if ( $login->login == '' ) { //if login is empty > > $valid = 'true'; //make valid true > > }else{ //else > > $valid = 'false'; //make valid false > > } > > $this->view->valid = $valid; //pass the valid to view > > } > > > Checklogin view (checklogin.phtml): > > > <?php > > echo $this->valid; //show result of valid > > ?> > > > Registration form view: > > > ... > > <script type="text/javascript" src="<?php echo $this->baseUrl;?>/ > > public/scripts/jquery.js"></script> > > <script type="text/javascript" src="<?php echo $this->baseUrl;?>/ > > public/scripts/jquery.validate.js"></script> > > ... > > <script type="text/javascript"> > > $(document).ready(function() { > > // validate signup form on keyup and submit > > var validator = $("#signupform").validate({ > > rules: { > > login: { > > required: true, > > minlength: 2, > > remote: "checklogin" <-- dosen't work > > }, > > pass: { > > required: true, > > minlength: 5 > > }, > > pass_confirm: { > > required: true, > > minlength: 5, > > equalTo: "#pass" > > } > > > }, > > messages: { > > login: { > > required: "Enter login", > > minlength: jQuery.format("Enter at least {0} > > characters"), > > remote: jQuery.format("{0} is already in > > use") > > }, > > pass: { > > required: "Enter password", > > minlength: jQuery.format("Enter at least {0} > > characters") > > }, > > pass_confirm: { > > required: "Repeat password", > > minlength: jQuery.format("Enter at least {0} > > characters"), > > equalTo: "Powtórzone hasło jest > > nieprawidłowe" > > } > > }, > > // set this class to error-labels to indicate valid fields > > success: function(label) { > > // set as text for IE > > label.html(" ").addClass("checked"); > > } > > }); > > }); > > </script> > > ... > > <form action="" id="signupform" autocomplete="off" method="post"> > > <label for="login">Login*:</label><br /> > > <input id="login" type="text" name="login" /><span > > class="status"></span><br /> > > > <label for="pass">Password*:</label><br /> > > <input id="pass" type="password" name="pass" /><span > > class="status"></span><br /> > > > <label for="pass">Confirm password*:</label><br /> > > <input id="pass_confirm" type="password" name="pass_confirm" / > >><span class="status"></span><br /><br /> > > <input type="submit" name="signup" value="Register" /> > > </form> > > ... > > > The main problem is in '..remote: "checklogin"...'. This function > > dosen't work even I put in checklogin method only $this->views->valid > > = 'false' . The registration form view and checklogin view works with > > the same controller. > > > I don't now why its dosen't work. Please help! > > > David