clbond / ng2-redux-form

Connect Angular 2 forms to Redux stores
17 stars 7 forks source link

How to validate form? #11

Closed Redigast13 closed 7 years ago

Redigast13 commented 7 years ago

Hello! I created a form like the form from examples folder. If I change values then action.payload.valid always equals TRUE. I tried to use formControl directive, but then there is no @@ng2-redux-form/FORM_CHANGED action on form changed. Can you please give me an example of form validation.

Here is my form:

<form (ngSubmit)="onSubmit()" novalidate connect="form1">
    <div class="form-group has-feedback">
        <input type="email" class="form-control" placeholder="Email" ngModel name="email">
    </div>
</form>
clbond commented 7 years ago

You can use Angular form validation or Redux state validation. If you use Angular you need to take the novalidate attribute off your <form> element and create a custom validation directive (Google for examples) or one of the prepackaged validators like "required" or "pattern". (Eg try adding required to your <input> tag). I'll add some validation examples to the package this weekend