JavaScript禁用所需的消息

时间:2018-06-12 08:54:04

标签: javascript jquery html

当用户选择Chapel选择否时,我试图在表单中禁用所需的消息 所以基本上,它需要隐藏Chapel下拉菜单,它应该正常提交表格。当我点击单选按钮"否"并填写表格,当我按提交按钮时,内容消失,并显示所需的消息。 所以我的代码如下:



$(document).ready(function() {
  $("input[name$='Chapel']").click(function() {
    var test = $(this).val();
    if (test == 'No') {
      $("div#hideChapel").hide();
    } else {
      $("div#hideChapel").show();
    }
  });
});
history.pushState(null, null, document.URL);
window.addEventListener('popstate', function() {
  history.pushState(null, null, document.URL);
});


function ifChapelIsNo() {
  var radionbutton_No = document.getElementById('No');
  var radioButton_Yes = document.getElementById('Yes');

  if (radioButton_Yes = true) {
    window.location.href = '/ContractViewModels/ManualPayment';
  } else if (radionbutton_No == true) {
    window.location.href = '/ContractViewModels/ManualPayment';
  }
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="col-md-9">
  <label class="radio-inline">
<div class="choice" id="uniform-Yes"><span><input class="styled" htmlattributes="{ checked = true }" id="Yes" name="Chapel" type="radio" value="Yes" autocomplete="off"></span></div>
                                        Yes
</label>
  <label class="radio-inline">
<div class="choice" id="uniform-No"><span class="checked"><input checked="checked" class="styled" htmlattributes="{ checked = true }" id="No" name="Chapel" type="radio" value="No" autocomplete="off"></span></div>
                                        No
</label>
  <span class="field-validation-valid text-danger" data-valmsg-for="Chapel" data-valmsg-replace="true"></span>
</div>
&#13;
&#13;
&#13;

我认为错误是在HTML中的某个地方,也许我会错过一些ID或值来定义

图像

https://imgur.com/8E02PPZ

https://imgur.com/P98c8OT

https://imgur.com/IRIgLOL

2 个答案:

答案 0 :(得分:2)

您的代码中似乎存在拼写错误。您使用from six.moves.http_cookies import Morsel Morsel._reserved[str('samesite')] = str('SameSite') 进行比较,而应该是===

===

答案 1 :(得分:0)

基本上,在模型中只需禁用 必需 字段和脚本工作。非常感谢你们的帮助。