我的表单需要使用js进行验证并警告任何错误,然后返回存在输入值的表单,以便他们可以在重新提交之前修复它。一旦验证通过,它应该重定向到php“谢谢”页面。验证逻辑工作正常,但是在错误警报后,它会过早地重定向到php页面。
我的表单:
<form method = "post" name= "account" action= "validated.php" target="_blank">
<div>
<label for="fname"><span class="red">*</span> First Name:</label><br>
<input type="text" id="fname" name="fname" size="40" required><br>
<label for="lname">Last Name:</label><br>
<input type="text" id="lname" name="lname" size="40">
</div>
<div>
<label for="bdate">Birth Date:</label><br>
<input type="text" id="bdate" name="bdate" placeholder="dd/mm"><br>
<label for="email"><span class="red">*</span> Email Address:</label><br>
<input type="email" id="email" name="email" size="40" placeholder="mymail@mymail.com" required>
</div>
<div>
<p id="interests">Product Interests:</p>
<div class= "pref">
<input type="checkbox" class="preferences" name="interests[]" value="donuts">
<label for="donuts">Donuts</label>
</div>
<div class= "pref">
<input type="checkbox" class="preferences" name="interests[]" value="vanilla slice">
<label for="vanillaSlice">Vanilla Slice</label>
</div>
<div class= "pref">
<input type="checkbox" class="preferences" name="interests[]" value="randy tarts">
<label for="randyTarts">Randy Tarts</label>
</div>
<div class= "pref">
<input type="checkbox" class="preferences" name="interests[]" value="custard tarts">
<label for="custardTarts">Custard Tarts</label>
</div>
莫回无
慕尼黑8549860
相关分类