请帮帮我。
我有日期选择器,我希望用户只需readonly
,而不是更改已选择的日期。
<td class="contentdata fontSize07">
<input type="text" autocomplete="off" name="EntDate1" id="date1" class="textinputdasar fontSize08 marginLeft1" placeholder="Entertainment Date" value="<?php echo $EntDate1 ?>" required>
<div class="margine1"></div>
</td>
答案 0 :(得分:1)
html中有一个名为readonly
的属性会禁用输入字段以接受值。
<input type="text" name="date" value="2/2/2019" readonly />
答案 1 :(得分:0)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/jquery-validation@1.17.0/dist/jquery.validate.js"></script>
<script>
$(document).ready(function(){
$("#commentForm").validate();
});
function addInput() {
var indexVal = $("#index").val();
var index = parseInt(indexVal) + 1
var obj = '<input id="list'+index+'" name=list['+index+'] class="required" />'
$("#parent").append(obj);
$("#list"+index).rules("add", "required");
$("#index").val(index)
}
</script>
<form id="commentForm" method="get" action="">
<input type="hidden" name="index" name="list[1]" id="index" value="1">
<p id="parent">
<input id="list1" class="required" />
</p>
<input class="submit" type="submit" value="Submit"/>
<input type="button" value="add" onClick="addInput()" />
</form>
将<td class="contentdata fontSize07"><input readonly type="text" autocomplete="off" name="EntDate1" id="date1" class="textinputdasar fontSize08 marginLeft1" placeholder="Entertainment Date" value="<?php echo $EntDate1 ?>" required><div class="margine1"></div></td>
属性添加到输入