IE阻止更改组上选定的单选按钮

时间:2017-06-14 19:47:59

标签: javascript jquery

以下代码适用于Chrome,可防止根据字段验证更改所选单选按钮,但在IE上它将取消选中所有单选按钮。

预期的行为:就像在Chrome中一样,它不应该让用户通过保留选中的单选按钮来更改所选的单选按钮,具有相同的检查状态。

$(document).ready(function(){
	$("[name=group1]").on("click", function(event){
  	var dynamicValidation = false; //mock a field validation
    if (!dynamicValidation){
    	return false;
    }
  })
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input id="radio1" type="radio" name="group1" value="1" checked="checked"> 
<label for="radio1">Option1</label>

<input id="radio2" type="radio" name="group1" value="2">
<label for="radio2">Option2</label>

1 个答案:

答案 0 :(得分:0)

不确定您是否需要已经检查过无线电,但这是一种解决方法。这应该适用于IE和Chrome。

import PyPDF2
import os

directory = 'C:\\Users\\jmoorehead\\Desktop\\A2IReports\\'
for file in os.listdir(directory):
    if not file.endswith(".pdf"):
        continue
    with open(os.path.join(directory,file), 'rb') as pdfFileObj:  # Changes here
        pdfReader = PyPDF2.PdfFileReader(pdfFileObj)
        pageObj = pdfReader.getPage(0)
        if "There is no data to present that matches the selection criteria" in pageObj.extractText():
            print("{} was removed.".format(file))
            os.remove(file)
$(document).ready(function() {

  var dynamicValidation = false; //mock a field validation
  if (!dynamicValidation) {
    $("input[type=radio]").attr('disabled', true);
  }

});