Skip to content

Instantly share code, notes, and snippets.

@brachi-wernick
Last active December 28, 2017 17:29
Show Gist options
  • Save brachi-wernick/d6c162fd3f17d5d09c238250948209bc to your computer and use it in GitHub Desktop.
Save brachi-wernick/d6c162fd3f17d5d09c238250948209bc to your computer and use it in GitHub Desktop.
form with require if conditional validator
<h3>My children </h3>
<div class="form-check">
<label class="form-check-label">
<input class="form-check-input" type="checkbox" [(ngModel)]="hasChildren" name="hasChildren"> I do not have any children
</label>
</div>
<div class="form-group">
<label>Name</label>
<input type="text" class="form-control" name="child1Name"
[(ngModel)]="child1Name"
[requiredIf]="!hasChildren" >
</div>
<div class="form-group">
<label>birth Date</label>
<input type="date" class="form-control" name="child1Birthdate"
[(ngModel)]="child1Birthdate"
[requiredIf]="!!child1Name">
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment