我的 Jquery 注册验证有问题。如果您不填写名称,我将无法返回错误消息。
jQuery(document).ready(function () {
$('#register').submit(function () {
var action = $(this).attr('action');
var error = '<div class=\"states\"><li class=\"warning\"><strong>Fout!</strong><br /> U hebt geen naam opgegeven.</li> <br /></ul>';
$(".states li").slideUp(750, function () {
$('.states li').hide();
$('#submit')
.after('<img src="images/ajax-loader.gif" class="loader" />')
.attr('disabled', 'disabled');
$.post(action, {
name: $('#name').val(),
realname: $('#realnam').val(),
pass: $('#pass').val(),
repeatpass: $('#repeatpass').val(),
mail: $('#mail').val(),
mailadres: $('#mailadres').val(),
});
if (name == "") {
$(error).slideDown('slow');
}
});
return false;
});
});
还有我的 HTML 代码:
<script src="js/aanmelden.js"></script>
<?php
include_once 'include/config.php';
?>
<div class="text-section">
<h1>Aanmelden</h1>
<p>Hier kunt u zich <strong>gratis</strong> aanmelden op <?php echo $sNaam; ?></p>
</div>
<div class="states">
<li class="warning"><strong>Waarschuwing</strong> Deze pagina is (nog) niet af, hier wordt aangewerkt.</li> <br />
</ul>
<form method="POST" action="bin/register.php" id="register">
<fieldset>
<legend>Naam</legend>
<label id="username">Gebruikersnaam:</label>
<input type="text" class="text" name="gebruikersnaam" id="name" placeholder="Uw gebruikersnaam" /> <br />
<label id="realname">Uw echte naam:</label>
<input type="text" class="text" name="echtenaam" id="realnam" placeholder="Uw echte naam" /> <br />
</fieldset>
<fieldset>
<legend>Wachtwoord</legend>
<label id="password">Uw wachtwoord:</label>
<input type="password" class="text" id="pass" name="wachtwoord" placeholder="Uw wachtwoord" /> <br />
<label id="repeatpassword">Uw wachtwoord nogmaals:</label>
<input type="password" class="text" id="repeatpass" name="hwachtwoord" placeholder="Uw wachtwoord nogmaals" /> <br />
</fieldset>
<fieldset>
<legend>Mail</legend>
<label id="mailadres">Uw mail adres:</label>
<input type="text" class="text" name="mail" id="mail" placeholder="Uw mail adres" /> <br />
<label id="repeatmail">Uw mail adres nogmaals:</label>
<input type="text" class="text" name="hmail" id="mailadres" placeholder="Uw mail adres nogmaals" /> <br />``
</fieldset>
<input type="submit" name="submit" value="Registreren" class="orange" id="submit" />
<br />
</form>
我的问题(在http://mijnrpg.eu演示,然后是第二个选项卡)。如果您单击显示“Registreren”的按钮,您将明白我的意思。它没有给出错误。