繁体   English   中英

使用内置的Magento表单验证将单选框设置为必填项

[英]Set a radio box as a required entry with the built-in Magento form validation

我已经创建了一些用于Magento单页结帐的复选框,我想使用验证来确保客户选择其中之一,否则javascript将显示内置的Magento表单验证。

<div>
 <li class="control horiz-list">
 <input type="radio" class="radio organisation_type validate-one-required" value="1" id="billing:organisation_type" name="billing[organisation_type]"> <?php echo $this->__('A') ?></li>
 <li class="control horiz-list">
 <input type="radio" class="radio organisation_type validate-one-required" value="2" id="billing:organisation_type" name="billing[organisation_type]"> <?php echo $this->__('B') ?></li>
 <li class="control horiz-list">
 <input type="radio" class="radio organisation_type validate-one-required" value="3" id="billing:organisation_type" name="billing[organisation_type]"> <?php echo $this->__('C') ?></li>
</div>

更新:我现在更改了代码块(如上所述)-验证有效,但我提交的错误显示在元素的末尾而不是块的末尾,因此格式不太正确。

谁能建议我如何使错误正确显示在元素的末尾?

在单选按钮的类名称中使用需要validate-one-required-by-name名称。

要么

在组中的最后一个单选/复选框上使用需要validate-one-required

暂无
暂无

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

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