i m using Angular 2.0 and want to validate form and want to write pattern
in input type="text" (it can't be number and the validation can't be with
JS) that allow me to enter only numbers, min:1 and max:30? with some
conditional:
Here is my form dateForm and based on Holidays i want to select my
[attr.pattern] so my questions are
: 1. Can we validate it in HTML tag itself? I tried but pattern is not
working with condition (true/false)
2. If not then how to use Angular but not sure how my Form get invalidate.
As if i do validation in onChange then how my form get invalidate at the
time of submit.
<div class="panel panel-default">
<div class="panel-header">
<div class="row">
<div class="col-xs-4">
<label class="select-all">
<input type="checkbox" id="selectAllCheckbox"
[(ngModel)]="isSelectAll" (change)="selectAllOnChange($event)"> Select All
</label>
</div>
<div class="col-xs-4 float-right">
<select class="form-control input-sm"
[(ngModel)]="selectedDays">
<option value="op1">Days</option>
*<option value="op2">Holidays</option>*
</select>
</div>
</div>
</div>
<div class="panel-body">
<form #dateForm="ngForm">
<div class="row">
<div class="col-xs-3 col-periodicity">
<div class="form-inline">
<label class="checkbox-inline">
<input type="checkbox" id="checkbox" name="checkbox"
[(ngModel)]="periodicObj[0].ischecked"
(change)="daysSelectionOnChange($event,0)"> Day1
</label>
<div class="form-group">
<input type="text" name="days"
*[**attr.pattern]="selectedDays === 'op2' ?([1-9]|[12]\d|3[01]): false"*
[required]="selectedDays === 'op2' && perObj[0].ischecked"
[(ngModel)]="perObj[0].daysAfterMonthEnd"
class="form-control input-sm input-periodicity">
</div>
</div>
</div>
<!-- .col-xs-3 -->
</div>
<!-- .row -->
</form>
</div>
</div>
<!-- .panel-body -->
</div>
<!-- .panel-default -->
--
You received this message because you are subscribed to the Google Groups
"Angular" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.