Vue-form-generator: How do you validate radio buttons?

Created on 11 May 2017  路  5Comments  路  Source: vue-generators/vue-form-generator

Hello

How do you validate radio buttons?

I do not see a validator in validators.js file

question

Most helpful comment

Hi, thanks the fiddle. I updated: https://jsfiddle.net/p66mv49o/10/

So I used required validator for radios: validator: VueFormGenerator.validators.required
And created a custom validator for agree checkbox:

validator: function(value) {
    if (value !== true)
        return ["Please agree!"];
}

And you need to define onSubmit handler in the schema.

All 5 comments

How you can validate it? Could you post a fiddle with example?

Hello

I have created a fiddle here: https://jsfiddle.net/sjordan/p66mv49o/8/

Hope you don't mind, I expanded the question to:

  • How do I validate radio buttons? (In my example, one value must be selected before the form is allowed to be submitted)

  • How do I validate checkbox? (In my example, I want the checkbox to be checked before the form is allowed to be submitted)

Hi, thanks the fiddle. I updated: https://jsfiddle.net/p66mv49o/10/

So I used required validator for radios: validator: VueFormGenerator.validators.required
And created a custom validator for agree checkbox:

validator: function(value) {
    if (value !== true)
        return ["Please agree!"];
}

And you need to define onSubmit handler in the schema.

@icebob Thank you. I'll try to incorporate this into my code.

@icebob Thank you

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Atiladanvi picture Atiladanvi  路  4Comments

kiankji picture kiankji  路  4Comments

miseeger picture miseeger  路  4Comments

afourmeaux picture afourmeaux  路  4Comments

pimhooghiemstra picture pimhooghiemstra  路  5Comments