开发者

Why the remote validation doesn't work?

I follow the demo http://jquery.bassistance.de/validate/demo/marketo/ and met some problems to achieve the same remote validation function.

Here is HTML I 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. It has been highlighted below'
     : 'You missed ' + errors + ' fields.  They 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 to go to the other开发者_开发百科 step");
  },
  messages: {
   password2: {
    required: " ",
    equalTo: "Please enter the same password as above" 
   },
   email: {
    required: " ",
    email: "Please enter a valid email address, example: you@yourdomain.com",
    remote: jQuery.validator.format("{0} is already taken, please enter a 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 is the 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 as $email) {
 if( strtolower($email) == $request )
  $valid = 'false';
}
echo $valid;
?>

When I enter glen@marketo.com and then click TAB, I found the 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 that it complains the $_REQUEST['value']

How can I fix this problem.

Many thanks


It should be $_REQUEST['email'] instead of $_REQUEST['value']

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜