How to validate radio button in magento?
Asked Answered
C

2

16

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.

Thanks

Chiccory answered 12/10, 2013 at 11:16 Comment(0)
C
42

i got the answer,

use validate-one-required-by-name in the class name of the radio button.

Cheers

Edit:

or

use validate-one-required on the last radio/checkbox in the group

Thanks to Rahul Tripathi

Chiccory answered 12/10, 2013 at 11:16 Comment(2)
To add to it:- use class="validate-one-required" and place it on the last radio/checkbox in the group. Make sure there's a parent div wrapping around the groupPadauk
Perfect, just what I was looking for.Nial
W
0

Validation works, but to show error message you can't use any wrappers. Just

 <label> and <input>
Washtub answered 18/10, 2019 at 20:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.