禁用复选框

发布于 2024-08-24 22:57:45 字数 200 浏览 6 评论 0原文

我的表单中基本上有几个复选框,它们不是数据库项,而是根据数据库列检索源值。

由于我不希望用户能够更改这些复选框,因此我禁用了这些复选框。

当我查询记录时,启动时的表单会毫无问题地检索复选框的值。

问题是,当我在提交页面时在表单上遇到验证错误时,最初检索为“Y”(即选中)的复选框值现在为空。

发生验证错误时如何维护这些值?

I basically have a couple of checkboxes in my form, that are not database items but am retrieving the source value based on a database column.

As I do not want the user to be able to change these checboxes, I have disabled these checkboxes.

When I query a record, the form at start-up retrieves the value for the checkbox with no issues.

The problem is, when I hit a validation error on my form when the page is submitted, my checkbox values that were originally retrieved as 'Y', i.e checked are now null.

How can I maintain these values when a validation error occurs?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

调妓 2024-08-31 22:57:45

禁用的控件不会成功(这就是禁用的要点)。

要么使用readonly控件,要么使用hidden输入。

A disabled control will not be successful (that's the point of disabled).

Either go with a readonly control instead, or use a hidden input.

后知后觉 2024-08-31 22:57:45

您可以在发布表单之前启用相关复选框。然后它们将被“刚刚送回”,(希望)完好无损。

与往常一样,您必须进行服务器端检查,并且不要期望表单值和/或 javascript 未被篡改。

You can enable the checkboxes in question just before you post the form. Then they will be "just sent back", (hopefully) untouched.

As always, you must do your server side checks and not expect that form values and/or javascript have not been tampered with.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文