我已经完成了带有即时字段验证的代码,但也希望在字段没有值的情况下防止提交表单。我已经设法阻止提交表单,但是当我返回并提供一个值时,它仍然不允许它提交。知道我在这里做错了什么吗?
这是 HTML:
<form id="contactForm" action="https://formspree.io/xrggbejj" method="POST" onsubmit="return formValidation(contactForm);">
<div class="row">
<div class="col">
<label for="fName">First Name</label>
</div>
<div class="col">
<input type="text" id="fName" name="firstname" onblur="checkFirstName(firstName)" autofocus/>
<img src="../images/alert-icon.png" class="alert" id="firstNameMsg" alt="alert icon" width="40" height="35"/>
</div>
</div> <!-- End of row -->
<div class="row">
<div class="col">
<label for="lName">Last Name</label>
</div>
<div class="col">
<input type="text" id="lName" name="lastname" onblur="checkLastName(lastName)"/>
<img src="../images/alert-icon.png" class="alert" id="lastNameMsg" alt="alert icon" width="40" height="35"/>
</div>
</div> <!-- End of row -->
<div class="row">
<div class="col">
<label for="subject">Questions and/or Comments</label>
</div>
<div class="col">
<textarea id="subject" name="subject" onblur="checkSubject(subject)" style="height:200px"></textarea>
<img src="../images/alert-icon.png" class="alert" id="subjectMsg" alt="alert icon" width="40" height="35"/>
</div>
</div> <!-- End of row -->
<div class="row">
<input type="submit" value="SEND" />
</div> <!-- End of row -->
</form>
湖上湖
至尊宝的传说
相关分类