以下代码存在问题。目前的代码不起作用,但如果我在 check-main.php 中删除$.ajax({...
,那么我想要的就是所有工作。
重点是:修复与 check-email.php 相关联的$.ajax({...
。
此$.ajax({...
应显示类似函数的错误,密码为 chkpass = 0; 。
信息:以下代码必须实时工作 - 检测按钮上是否存在电子邮件点击onclick =" checkStepOne();"并且不应该在输入中删除提供的电子邮件。
为registration.php
<form method="post" action="" id="frmEmailSignup" onsubmit="return submitResform();">
<div class="step step-1">
<section>
<h1><?=$lang['i_040']?></h1>
<div class="col-left">
<p class="prompt"><?=$lang['i_009']?></p>
<ul>
<li>
<a href="system/user-login/google.php" id="googlelogin" class="btn-blue googlelogin"><?=$lang['i_011']?></a>
<div class="clear"></div>
</li>
<li style="padding-top: 0px;">
<a href="system/user-login/microsoft.php" class="btn-blue officelogin" id="officelogin"><?=$lang['i_012']?></a>
<div class="clear"></div>
</li>
</ul>
</div>
<div class="col-right">
<p class="prompt"><?=$lang['i_010']?></p>
<ul>
<li>
<label class="side-label" for="owner[email]"><?=$lang['i_013']?></label>
<input type="email" class="email required" id="owner_email" name="owner[email]" placeholder="<?=$lang['i_013']?>" tabindex="0" onkeyup="return forceLower(this);" style="margin-bottom: 6px;"/>
<?php if ($db->QueryGetNumRows("SELECT * FROM users WHERE login='".$login."' OR email='".$email."' LIMIT 1") > 0) { ?>
<label class="error" style="margin-top: -9px;"><?=$lang['w_024']?></label>
<?php } else { ?>
<label class="error" style="margin-top: -9px;"><?=$lang['i_014']?></label>
<?php } ?>
<span class="check"></span>
</li>
<li class="password-row">
<label class="side-label" for="owner[password]"><?=$lang['i_015']?></label>
<input type="password" class="password required" id="owner_password" name="owner[password]" placeholder="<?=$lang['i_015']?>" tabindex="0"/>
<label class="error"><?=$lang['i_016']?></label>
<span class="check"></span>
</li>
<li class="full">
<button type="button" class="button cta btn-disabled next next-one" tabindex="0" data-plan="register" onclick="checkStepOne();"><?=$lang['i_017']?></button>
</li>
</ul>
</div>
</section>
</div>
<div class="step step-2">
<section>
<h1><?=$lang['i_018']?></h1>
<ul>
<li>
<input type="text" class="password required" id="FirstName" name="owner[FirstName]" placeholder="<?=$lang['i_019']?>" style="width: 48.5%; text-transform: capitalize;"/>
<input type="text" class="password required" id="LastName" name="owner[LastName]" placeholder="<?=$lang['i_020']?>" style="width: 48.5%; float: right; text-transform: capitalize;"/>
<label class="error error-w-form"><?=$lang['i_021']?></label>
<span class="check"></span>
</li>
</br>
<div class="centero" name="gender">
<fieldset class="material-female" style="margin-right: 20px;">
<div>
<input type="radio" name="owner[gender]" class="required check-reg" value="female">
<div class="check">
<span>
<svg viewBox="0 0 24 24"><g><line x1="4.5" x2="9.24" y1="12.5" y2="17.24"></line><line x1="9.24" x2="19.76" y1="17.24" y2="6.73"></line></g><g><line x1="4.5" x2="9.24" y1="12.5" y2="17.24"></line><line x1="9.24" x2="19.76" y1="17.24" y2="6.73"></line></g></svg>
</span>
<label><?=$lang['i_022']?></label>
</div>
</div>
</fieldset>
<fieldset class="material-male">
<div>
<input type="radio" name="owner[gender]" class="required check-reg" value="male">
<div class="check">
<span>
<svg viewBox="0 0 24 24"><g><line x1="4.5" x2="9.24" y1="12.5" y2="17.24"></line><line x1="9.24" x2="19.76" y1="17.24" y2="6.73"></line></g><g><line x1="4.5" x2="9.24" y1="12.5" y2="17.24"></line><line x1="9.24" x2="19.76" y1="17.24" y2="6.73"></line></g></svg>
</span>
<label><?=$lang['i_023']?></label>
</div>
</div>
</fieldset>
</div>
<li class="full create">
<input type="submit" class="button cta next create-account" value="<?=$lang['i_002']?>" name="register"/>
<p class="agreement"><?=$lang['i_024']?></p>
</li>
</ul>
</section>
<?=$footerLinks?>
</div>
</form>
检查-main.php
<script>
function forceLower(strInput) {
strInput.value=strInput.value.toLowerCase();
}
function checkStepOne() {
jQuery("#owner_email").parents("li").find("label.error").hide();
jQuery("#owner_password").parents("li").find("label.error").hide();
jQuery("#owner_email").parents("li").find("span.check").removeClass('chkValid');
jQuery("#owner_password").parents("li").find("span.check").removeClass('chkValid');
var owner_email = jQuery("#owner_email").val();
var owner_password = jQuery("#owner_password").val();
var chkemail = 1;
var chkpass = 1;
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
if (owner_email == "") {
chkemail = 0;
}
if (reg.test(owner_email) == false) {
chkemail = 0;
}
$.ajax({
type: "POST",
url: "check-email.php",
data: datastring,
success: function(owner_email) {
if (owner_email == 0) {
chkemail == 1;
jQuery("#owner_email").parents("li").find("span.check").addClass('chkValid');
} else {
chkemail == 0;
jQuery("#owner_email").parents("li").find("label.error").show();
}
}
});
if (owner_password == "") {
chkpass = 0;
}
if (owner_password.length < 5) {
chkpass = 0;
}
if (chkpass == 1) {
jQuery("#owner_password").parents("li").find("span.check").addClass('chkValid');
} else {
jQuery("#owner_password").parents("li").find("label.error").show();
}
if (chkpass == 1 && chkemail == 1) {
jQuery(".step-1").hide();
jQuery(".step-2").addClass('chkValid').show();
}
return false;
}
function submitResform() {
var FirstName = jQuery("#FirstName").val();
var LastName = jQuery("#LastName").val();
if (FirstName && LastName) {
return true;
} else {
jQuery("#FirstName").parents("li").find("label.error").show();
return false;
}
}
</script>
检查-email.php
<?php
$email = $_POST['owner[email]'];
$query = mysql_query("SELECT email FROM users WHERE email = '$email'");
if (mysql_num_rows($query) == 1) {
echo '1';
} else {
echo '0';
}
?>