V
V
Vassa2014-06-26 21:52:48
Angular
Vassa, 2014-06-26 21:52:48

How to validate a form that has branching logic with hidden fields?

How to be in a situation when the form in itself contains logic and hidden fields that are displayed depending on the selected previous value. Those. The problem is that hidden fields are also validated, although they should not affect the validation result themselves, since according to the logic of filling out the form, they did not have to be displayed.
Example
Radio button select Pizza or Soup: Selected
1st - Pizza -> show three select fields:
ingredient 1(ng-required)
ingredient 2(ng-required)
ingredient 3(ng-required)
Selected 2nd - Soup -> , 1 field-selector
name of the soup (ng-required) was added.
In fact, all fields that are ng-required will get into the form validation, although if we did not select Pizza, three fields must already be omitted from the validation.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2014-06-26
@Mr_Pukin

<select ng-model="ingridients" ng-required="type=='pizza'">...</select>
<input type=text ng-model="name"  ng-required="type!='pizza'" />

something like that.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question