从下拉列表中选择其他选项时激活文本框

时间:2015-03-15 14:32:09

标签: javascript php html5

我的电子邮件订购表格需要帮助。

当有人选择" Self-Collection"选项,它将使用户的日期和时间选择处于活动状态。我想让日期和时间选择成为必填字段。我该怎么办?

另请访问link here

添加以下代码后,无法发送电子邮件。

   <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")
    }
     });
    });

1 个答案:

答案 0 :(得分:0)

您是否尝试在选择按钮上放置必需的属性。

我编辑了我的答案。请检查。

$(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");
  }
  });
});