gpt4 book ai didi

javascript - Laravel 验证复选框

转载 作者:行者123 更新时间:2023-11-28 19:50:55 25 4
gpt4 key购买 nike

如何验证“表单中的两个复选框中至少有一个被选中”?我知道其他方法,但我想知道 laravel 中是否有对此的验证规则?

最佳答案

是的,我想这就是您要找的:

$rules = array(
'checkbox1' => 'required_without:checkbox2', //require if checkbox2 miss
'checkbox2' => 'required_without:checkbox1', //require if checkbox1 miss
);

因此,如果错过了这两个复选框,验证器将失败。

required_without:foo,bar,... The field under validation must be present only when any of the other specified fields are not present.

Doc

关于javascript - Laravel 验证复选框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23454658/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com