Zabs
Zabs

Reputation: 14142

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.

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?

Upvotes: 0

Views: 274

Answers (1)

drizzt13
drizzt13

Reputation: 649

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".

Upvotes: 2

Related Questions