我遵循演示http://jquery.bassistance.de/validate/demo/marketo/並遇到了一些問題以實現相同的遠程驗證功能。爲什麼遠程驗證不起作用?
這裏是我使用的HTML。
<!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: [email protected]",
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>
這裏是PHP腳本:
PARAM:電子郵件格倫
<?php
$request = trim(strtolower($_REQUEST['value']));
$emails = array('[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]');
$valid = 'true';
foreach($emails as $email) {
if(strtolower($email) == $request)
$valid = 'false';
}
echo $valid;
?>
當我進入[email protected]然後點擊TAB,我通過filebug發現以下錯誤消息@ marketo.com 迴應:
通知:未定義變量:中的請求C:\ wamp \ www \ ajax_login_上行驗證\ emails.php
通知:未定義指數:在C值:\瓦帕\ WWW \ ajax_login_validation \ emails.php線
真
它似乎抱怨$ _REQUEST ['值']
我該如何解決這個問題。
非常感謝
這是相當你必須有一個表。 – 2010-07-24 06:27:28