简体   繁体   English

如何验证magento中的单选按钮?

[英]How to validate radio button in magento?

In my custom module I have a form which has radio buttons. 在我的自定义模块中,我有一个带有单选按钮的表单。

When I click the submit button it does not validate the radio button. 当我单击提交按钮时,它不会验证单选按钮。

How to validate that using the Magento default validate class. 如何使用Magento默认验证类进行验证。

Thanks 谢谢

i got the answer, 我得到了答案,

use validate-one-required-by-name in the class name of the radio button. 在单选按钮的类名称中使用需要validate-one-required-by-name名称。

Cheers 干杯

Edit: 编辑:

or 要么

use validate-one-required on the last radio/checkbox in the group 在组中的最后一个单选/复选框上使用需要validate-one-required

Thanks to Rahul Tripathi 感谢Rahul Tripathi

Validation works, but to show error message you can't use any wrappers. 验证有效,但是要显示错误消息,您不能使用任何包装。 Just 只是

 <label> and <input>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM