简体   繁体   English

使用内置验证来验证在Magento中单击/选择的按钮

[英]Validate for a button click/selected in Magento using the built-in validation

I know the Magento validation javascript library is pretty powerful, however I am trying to make Magento recognise 3 buttons and have the user be forced to select one before they can proceed, is this possible using the current javascript library in Magento. 我知道Magento验证javascript库功能非常强大,但是我试图让Magento识别3个按钮,并迫使用户在继续操作之前不得不选择一个按钮,这是否可以使用Magento中的当前javascript库进行。

This isn't a problem usually but in this case rather than input buttons I am using a standard button (probably not the best way to approach this tbh) 通常这不是问题,但在这种情况下,我使用的是标准按钮(而不是输入按钮)(可能不是解决此问题的最佳方法)

<li class="fields">
    <div class="field">
       <button class="button organisation_type" value="1" type="button"><span><span><?php echo $this->__('Org A') ?></span></span></button>
       <button class="button organisation_type" value="2" type="button"><span><span><?php echo $this->__('Org B') ?></span></span></button>
       <button class="button organisation_type" value="3" type="button"><span><span><?php echo $this->__('Org C') ?></span></span></button>
    </div>
</li>

Is it possible using the built in library which uses the css classes to have this request the user to select one button from the three above? 是否可以使用使用css类的内置库来要求用户从上面三个中选择一个按钮?

is it possible for you to use radio-button instead of buttons? 您可以使用单选按钮代替按钮吗? if the answer is yes - then you can add 3 radio buttons (for the 3 organisations), give them the same name so the user can select only one value, and then add them the class "required-entry". 如果答案是肯定的,那么您可以添加3个单选按钮(对于3个组织),为其指定相同的名称,以便用户只能选择一个值,然后将其添加为“必填项”类。

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

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