I have an input and the type is number. I want to set min and max, if the input is out of this range (< min or >max), the error will be displayed.
My problem is that if the input is not empty but invalid, the error disappears (example: min =10, max =20, input =2000, still no error displays).
I search on this site and there is a post about validation but the solution is to use < md-input-container> and < md-error>. I don't want to use < md-input-container> and < md-error>.
Reference:here
Is there anyway to solve my problem?
My add-hero.component.html:
<div class="publishedYear">
<label>Publish Year: </label>
<input type="number" id="PublishedYear" name="PublishedYear" required min="10" max="20"
[(ngModel)]="hero.PublishedYear" #publishedYear="ngModel">
<p class="alert alert-danger invalid" *ngIf="publishedYear.errors">Invalid Published Year</p>
</div>
My Hero.ts
export class Hero {
Id: number;
Name: string;
PublishedYear: number;
Complete?: boolean;
}