嗨我对此票证有同样的问题,但文本框在gridview内部的唯一区别是在pageload中不可见,只有在满足特定条件时才可见。
How to make only some text in a text-box read-only while allowing the rest to be edited
香港专业教育学院尝试过以下代码,但它没有正确运行 任何帮助都将非常感谢,非常感谢你!
$(document).ready(function () {
var GVMaintainReceiptMaster = document.getElementById('<%= gvData.ClientID%>');
alert("test");
for (var rowId = 1; rowId < GVMaintainReceiptMaster.rows.length; rowId++) {
var txtbx = GVMaintainReceiptMaster.rows[rowId].cells[0].children[0];
var readOnlyLength = $(txtbx).val().length;
$(txtbx).on('keypress, keydown', function (event) {
if ((event.which != 37 && (event.which != 39))
&& ((this.selectionStart < readOnlyLength)
|| ((this.selectionStart == readOnlyLength) && (event.which == 8)))) {
return false;
}
});
alert(txtbx.value);
}