php - Why the remote validation doesn't work? -
i follow demo http://jquery.bassistance.de/validate/demo/marketo/ , met problems achieve same remote validation function.
here html used.
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/2000/rec-xhtml1-200000126/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>subscription signup | marketo</title> <!--http://jquery.bassistance.de/validate/demo/marketo/--> <link rel="stylesheet" type="text/css" media="screen" href="css/stylesheet.css" /> <script type="text/javascript" src="js/jquery/jquery-1.4.2.js" ></script> <script type="text/javascript" src="js/jquery/jquery.validate.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("#profileform").validate({ invalidhandler: function(e, validator) { var errors = validator.numberofinvalids(); if (errors) { var message = errors == 1 ? 'you missed 1 field. has been highlighted below' : 'you missed ' + errors + ' fields. have been highlighted below'; $("div.error span").html(message); $("div.error").show(); } else { $("div.error").hide(); } }, onkeyup: false, submithandler: function() { $("div.error").hide(); alert("submit! use link below go other step"); }, messages: { password2: { required: " ", equalto: "please enter same password above" }, email: { required: " ", email: "please enter valid email address, example: you@yourdomain.com", remote: jquery.validator.format("{0} taken, please enter different address.") } }, debug:true }); }); </script> </head> <body> <div> <form id="profileform" action="" method="post" > <div class="error" style="display:none;"> <img src="images/warning.gif" alt="warning!" width="24" height="24" style="float:left; margin: -5px 10px 0px 0px; " /> <span></span>.<br clear="all"/> </div> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td colspan="2"><h2 style="border-bottom: 1px solid #cccccc;">login information</h2></td> </tr> <tr> <td class="label"><label for="email">email:</label></td> <td class="field"><input id="email" class="required email" remote="emails.php" maxlength="40" name="email" size="20" type="text" tabindex="11" value="" /></td> </tr> <tr> <td class="label"><label for="password1">password:</label></td> <td class="field"><input id="password1" class="required password" maxlength="40" name="password1" size="20" type="password" tabindex="12" value="" /></td> </tr> <tr> <td class="label"><label for="password2">retype password:</label></td> <td class="field"><input id="password2" class="required" equalto="#password1" maxlength="40" name="password2" size="20" type="password" tabindex="13" value="" /> <div class="formerror"></div></td> </tr> <tr> <td></td> <td><div class="buttonsubmit"> <input class="formbutton" type="submit" value="next" style="width: 140px" tabindex="14" /> </div></td> </tr> </table> </form> </div> </body> </html>
here php script:
<?php $request = trim(strtolower($_request['value'])); $emails = array('glen@marketo.com', 'george@bush.gov', 'me@god.com', 'aboutface@cooper.com', 'steam@valve.com', 'bill@gates.com'); $valid = 'true'; foreach($emails $email) { if( strtolower($email) == $request ) $valid = 'false'; } echo $valid; ?>
when enter glen@marketo.com , click tab, found following error messages through filebug:
param: email glen@marketo.com response:
notice: undefined variable: request in c:\wamp\www\ajax_login_validation\emails.php on line 4
notice: undefined index: value in c:\wamp\www\ajax_login_validation\emails.php on line 5
true
it seems complains $_request['value']
how can fix problem.
many thanks
it should $_request['email']
instead of $_request['value']
Comments
Post a Comment