You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

求助:JavaScript实现DateKey列值显示后不可修改功能(附代码)

Solution to Lock #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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.13 06:28:25