我创建了一个注册表单。如果所有三个字段都有正确的值,则我提交表单。否则会显示错误并且表单未提交。在Chrome中JavaScript提交功能只能使用一次
function checkUserValidation() {
if ((validateEmail() == true) && (validatePassword() == true) && (validateRepeatPassword() == true)) {
document.getElementById('signup-form').submit(); // This works only first time in chrome..
return true;
} else {
return false;
}
}
<form id="signup-form">
<div class="container">
<label> <b>Email</b> </label>
<input id="signup-email" class="signup_field" type="text" name="signup-email" required onfocusout="validateEmail()" />
<label id="Invalid-Signup-Email" style="visibility:hidden;"></label>
<label> <b>Password</b> </label>
<input id="signup-pass" class="signup_field" type="password" name="signup-pass" required onfocusout="validatePassword()" />
<label id="Invalid-Signup-Pass" style="visibility:hidden;"></label>
<label> <b>Confirm your Password</b> </label>
<input id="signup-rep-pass" class="signup_field" type="text" name="signup-rep-pass" required onfocusout="validateRepeatPassword()" />
<label id="Invalid-Signup-Rep-Pass" style="visibility:hidden;"></label>
</div>
<div class="clearfix">
//following code does not work properly
<input class="signupbtn" type="button" name="signup" value="Sign Up" onclick="return checkUserValidation(); submit()" />
</div>
</form>
问题是submit
功能仅一次在Chrome(工作在IE罚款)。下一次,即使我输入了所有正确的值,表单也不会提交。
在Stack Overflow上提到的搜索和尝试的解决方案,但没有任何工作。
你能否介绍一下你已经尝试过的stackoverflow的解决方案,以便我们不会给你同样的建议。 –
请提供'validateEmail','validatePassword'和'validateRepeatPassword'来看看。这些方法可能是一个问题。 – MarceloBarbosa