[英]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.