求助:JavaScript实现DateKey列值显示后不可修改功能(附代码)
#input_DateKey After Assignment Hey there! Since you can't use your existing disable column function, here are a couple of simple, reliable ways to prevent users from modifying the #input_DateKey field once it gets populated with the queried data—just drop either of these into your "THIS PART" section:
Option 1: Use the disabled Attribute
This makes the input field grayed out and completely un-interactive (users can't click or type into it):
$("#input_DateKey").prop("disabled", true);
Note: If you later need to re-enable the field (like when #input_KindCode is changed to a value other than 1), add this line to your else block (right after EnableCol("DateKey")):
$("#input_DateKey").prop("disabled", false);
Option 2: Use the readonly Attribute
This lets users select and copy the text, but they can't edit it. The field won't look grayed out, keeping a more natural appearance:
$("#input_DateKey").prop("readonly", true);
To re-enable editing later, add this to your else block:
$("#input_DateKey").prop("readonly", false);
Quick Extra Tip (Important!)
I noticed your SQL query is directly concatenating user input values, which is a huge security risk (it leaves you open to SQL injection attacks). Whenever possible, use parameterized queries with your RunSql function instead of string concatenation—it's much safer.
内容的提问来源于stack exchange,提问作者user11174679

