我有一个.tpl文件,其中包含一个连接到js文件的表单,如果该表单是下面的表单之一,则该文件可以阻止页面执行任何操作:
但它似乎跳过所有内容并只运行注册页面
这是我的js代码
function registervalidation() {
var emailone = document.getElementById("emailone").value;
var emailtwo = document.getElementById("checkemail").value;
var firstname = document.getElementById("firstname").value;
var lastname = document.getElementById("lastname").value;
if(firstname == null || firstname == "")
{
document.getElementById("firstname").classList.add("warning");
return false;
}
if(lastname == null || lastname == "")
{
document.getElementById("lastname").classList.add("warning");
return false;
}
if (emailtwo == null || emailtwo == "" ) {
document.getElementById("emailtwo").classList.add("warning");
return false;
}
if(emailone !== emailtwo)
{
document.getElementById("emailtwo").classList.add("warning");
return false;
}
if(validateEmail(document.getElementById('emailone').value)){
}else{document.getElementById("emailone").classList.add("warning"); return false;}
if(validateEmail(document.getElementById('emailtwo').value)){
}else{document.getElementById("emailtwo").classList.add("warning"); return false;}
}
和我的表格
<script src="//<?=siteurl;?>/template/main/js/registervalidation.js"></script>
<div class="Grid-cell u-size35of4">
<div class="internal">
<h1 class="hevetics">Sign up</h1>
<p class="signuptext">It's free and always will be.</p>
<form action="/signup" name="register" method="post" class="ipetsignup" enctype="multipart/form-data" onsubmit="return registervalidation();">
<label>
<span><input id="firstname" type="text" name="firstname" placeholder="First Name" class="half" onchange="name();"/></span><input id="lastname" id="name" type="text" name="lastname" onchange="name();" placeholder="Last Name" class="half right" />
</label>
<label>
<input id="emailone" type="email" name="email" placeholder="Your Email" onchange="checkemails();" />
</label>
<label>
<input id="emailtwo" type="email" name="checkemail" placeholder="re-enter Email" onchange="checkemailtwo();" />
</label>
<label>
<input id="password" type="password" name="password" placeholder="New Password" />
</label>
<label>
<input id="signup" type="submit" class="button" value="Sign up" />
</label>
</form>
</div>
</div>