我的表格是我与联合材料和共同财产计划一起验证的。 在我试图检查密码是否吻合时,所有东西都相距甚远。
形式如下:
<div>
<label for="passlength">Password, valid: 0-9</label>
<input type="text" name="passlength" value="<?=@$_REQUEST[ passlength ]?>" id="passlength" />
<span id="validatePasslength"><?php if ($error) { echo $error[ msg ]; } ?></span>
</div>
<div>
<label for="passlength">Password2, valid: 0-9</label>
<input type="text" name="passlength2" value="<?=@$_REQUEST[ passlength2 ]?>" id="passlength2" />
<span id="validatePasslength2"><?php if ($error) { echo $error[ msg ]; } ?></span>
</div>
这就是 Java:
var r = $( #passlength ).val()
;
var validatePasslength2 = $( #validatePasslength2 );
$( #passlength2 ).keyup(function () {
var t = this;
if (this.value != this.lastValue) {
if (this.timer) clearTimeout(this.timer);
validatePasslength2.removeClass( error ).html( <img src="../../images/layout/busy.gif" height="16" width="16" /> checking availability... );
this.timer = setTimeout(function () {
$.ajax({
url: ajax-validation.php ,
data: action=check_passlength2&passlength= + r + &passlength2= + t.value,
dataType: json ,
type: post ,
success: function (j) {
validatePasslength2.html(j.msg);
}
});
}, 200);
this.lastValue = this.value;
}
});
这里是:
//Check for passlength
if (@$_REQUEST[ action ] == check_passlength && isset($_SERVER[ HTTP_X_REQUESTED_WITH ])) {
// means it was requested via Ajax
echo json_encode(check_passlength($_REQUEST[ passlength ]));
exit; // only print out the json version of the response
}
function check_passlength($password) {
// global $taken_usernames, $usersql;
$resp = array();
// $password = trim($password);
if (!preg_match( /^[0-9]{1,30}$/ , $password)) {
$resp = array("ok" => false, "msg" => "0-9 Only");
} else if (preg_match( /^[0-9]{1,2}$/ , $password)) {
$resp = array("ok" => false, "msg" => "Password too short");
} else if (preg_match( /^[0-9]{6,30}$/ , $password)) {
$resp = array("ok" => false, "msg" => "Password too long");
} else {
$resp = array("ok" => true, "msg" => "Password ok");
}
return $resp;
}
//Check for passlength2
if (@$_REQUEST[ action ] == check_passlength2 && isset($_SERVER[ HTTP_X_REQUESTED_WITH ])) {
// means it was requested via Ajax
echo json_encode(check_passlength2($_REQUEST[ passlength ],$_REQUEST[ passlength2 ]));
exit; // only print out the json version of the response
}
function check_passlength2($password,$password2) {
// global $taken_usernames, $usersql;
$resp = array();
// $password = trim($password);
if (!preg_match( /^[0-9]{1,30}$/ , $password2)) {
$resp = array("ok" => false, "msg" => "0-9 Only");
} else if (preg_match( /^[0-9]{1,2}$/ , $password2)) {
$resp = array("ok" => false, "msg" => "Password too short");
} else if (preg_match( /^[0-9]{6,30}$/ , $password2)) {
$resp = array("ok" => false, "msg" => "Password too long");
} else if ($password !== $password2) {
$resp = array("ok" => false, "msg" => "Passwords do not match");
} else {
$resp = array("ok" => true, "msg" => "Password ok");
}
return $resp;
}
I, pretty, is a issue with the j>, if I set : > >, 1234; It. ?