Codeigniter 验证

发布于 2024-08-16 10:42:13 字数 118 浏览 2 评论 0原文

基于后端数据,我可能会显示 n 个项目,以及用于选择和在页面上提供通信的复选框和文本区域,并且还向用户提供一个选项,以根据要求删除项目。我需要设置一个验证,例如至少需要一项。 由于其编号基于查询,因此不知道如何设置验证。

Based on the backend data i may have n number of items displayed along with the check box and textarea for selecting and give commnet on the page and there is also a option given to the user to remove the items based on the requirements. I need to set a validation like atlease one item is required.
Since its number is based on the query dont know how to set the validation.

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

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

发布评论

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

评论(1

辞取 2024-08-23 10:42:13

如果没有更多细节,很难说,但一般来说,如果您有一组复选框并且您想确保至少有一个被选中,您可以在 HTML 中执行此操作:

<p><input type="checbox" name="my_field_name[]" value="item1" />Item 1</p>
<p><input type="checbox" name="my_field_name[]" value="item2" />Item 2</p>
<p><input type="checbox" name="my_field_name[]" value="item3" />Item 3</p>

只需设置一条规则,即“my_field_name”是必填字段。假设它可以让您在一个数组中返回值,就像这样。

It's hard to say without a bit more detail, but in general if you have a set of checkboxes and you want to make sure at least one is checked you could do this in your HTML:

<p><input type="checbox" name="my_field_name[]" value="item1" />Item 1</p>
<p><input type="checbox" name="my_field_name[]" value="item2" />Item 2</p>
<p><input type="checbox" name="my_field_name[]" value="item3" />Item 3</p>

and just set a rule that "my_field_name" is a required field. That's assuming it works for you to have the values returned in one array like that.

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