【发布时间】:2023-04-10 16:14:01
【问题描述】:
我有一个 HTML 表单,提交后会发送一封邮件。我已经完成了邮件发送和其他所有工作,但是,我有一个特定的验证策略。需要填写电话号码或电子邮件字段。两者都不是必填字段,但使用 jQuery,我想至少将其中的一个设为必填。表格不得在没有电话或电子邮件的情况下提交。我是 jQuery 的新手。我的表格如下:
<form name="myform" id="myform" role="form" method="post" action="mail.php">
<div class="form-group">
<label for="Phone">Phone*:</label>
<input type="type" class="form-control" id="Phone" placeholder="Enter Phone">
<label for="fn">First Name*:</label>
<input type="type" class="form-control" id="fn" placeholder="Enter First Name" required>
</div>
<div class="form-group">
<label for="fn">Surname:</label>
<input type="type" class="form-control" id="fn" placeholder="Enter Surname">
<label for="email">Email:</label>
<input type="email" class="form-control" id="email" placeholder="Enter email">
</div>
<div class="form-group">
<button type="submit" class="btn submit pull-right">Submit</button>
</div>
</form>
【问题讨论】:
标签: javascript jquery validation