Make text fields required


#1

Hi. I’ve gone through the docs but didn’t find this. How can I make a textfield “required” like in HTML. So user gets an error on an empty field if he tries to submit the form with empty fields.


#2

Are you using a widget like the DataForm, or just regular elements?

Dataform does validation

But if you’ve just added some inputs yourself, you’re going to have to handle this all yourself in code. Either on submit validate the model to make sure everything has been filled out, or bind to the model to validate on demand.


#3

I’ve been using the regular elements I learnt from the tutorial. Wow this DataForm plugin seems powerful. I think this will solve my problem. Gonna try it out.

Thanks.


#4

Are you using Angular, if then you have built in libs to handle form validations. DataForm is also a nice option if that suits your requirement.


#5

No I’m using plain ol javascript