Input validation in Ionic


#1

Hi All,

I understand the benefits of Forms, Form Builder and Validators. I want to understand if there is a simpler validation technique in Ionic itself which can validate email, name, phone, location etc

Any guide shall be cool for me

Regards


#2

You must first understand that Formbuilder and FormGroups will validate all of inputs. So, your input will be invalid until all rules are ok (as all inputs)…
This is a bit of pain, if you have optional fields in a group.
The answer is to keep some fields out of validation in FormGroup.

It’s not a bug, it’s a feature, if you use FormBuilder, it expect all of the inputs to be checked to true or false. There is no optional check:(


#3

I agree. Therefore, I need more modular validator for my input fields. Any idea how I can do that? Let’s say name, email or phone?


#4

I found a way to use non-compulsory fields inside of a formGroup, but it’s basic with ng controls.