[英]activate a textbox on selecting other option from dropdown list
I need help with my email order form. 我的电子邮件订购表需要帮助。
When someone selects the "Self-Collection" option, it will make the date and time selection active for the user. 当有人选择“自收集”选项时,它将使用户选择日期和时间。 And I want to make the date and time selection a required field. 我想将选择日期和时间作为必填字段。 How can I do it? 我该怎么做?
And also please visit the link here . 另外,请访问此处的链接 。
After adding the code below, the email cannot be sent. 添加以下代码后,将无法发送电子邮件。
<div class="section colm colm6">
<label class="field select">
<select name="select" id="select">
<option value="">Delivery Methods...</option>
<option value="Register-Mail"> Register Mail </option>
<option value="Normal-Mail"> Normal Mail </option>
<option value="Self-Collection"> Self-Collection </option>
<option value="QVOO-Delivery"> QVOO Delivery (+$8) </option>
</select>
<i class="arrow double"></i>
</label>
</div>
</div><!-- end frm-row section -->
<center><strong><p>**WE will re-confirm your self collection date once your order arrives</p></strong></center>
<div class="section colm colm6">
<label class="field select">
<select id="Self-Collection" name="Self-Collection" disabled='disabled'>
<option value="">Self Collection Date... </option>
<option value="Monday After 7pm">Monday After 7pm</option>
<option value="Wednesday After 7pm"> Wednesday After 7pm </option>
<option value="Friday After 7pm"> Friday After 7pm </option>
<option value="Saturday Day 9am-2pm"> Saturday Day 9am-2pm </option>
<option value="Sunday 9am-2pm"> Sunday 9am-2pm </option>
</select>
<i class="arrow double"></i>
</label>
</div>
$(document).ready(function () {
$("#select").change(function () {
if ($(this).find("option:selected").val() == "Self-Collection") {
$("#Self-Collection").removeAttr("disabled")
} else {
$("#Self-Collection").attr("disabled","disabled")
}
});
});
have you tried placing required attribute on your select button. 您是否尝试过将必填属性放置在选择按钮上。
I have edited my answer. 我已经编辑了答案。 Please check. 请检查。
$(document).ready(function () {
$("#select").change(function () {
if ($(this).find("option:selected").val() == "Self-Collection") {
$("#Self-Collection").removeAttr("disabled");
$("#Self-Collection").attr("required","true");
} else {
$("#Self-Collection").attr("disabled","disabled");
$("#Self-Collection").removeAttr("required");
}
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.