简体   繁体   中英

how to type only specific characters into inputbox by angular2, validations

I want to insert only specific characters such like '7' and '8' into inputbox. When I add validations and user input type="number" and min="7" max="8", i can insert other keys but during the next process I get validation messages. I could not find how to write specific characters before validation occurs.

Regards Alper

My Snippet :

 <input type="number" min="0" max="12" name="input8">

try this

 <form [formGroup]="form" (ngSubmit)="submit()">
   <input type="number" min="0" max="12" name="input8" formControlName="input8" required>
   <span *ngIf="input8.touched && input8.errors">
    <span *ngIf="input8.errors.minlength">
    number at list 7 digit
    </span>
    <span *ngIf="input8.errors.maxlength">
    number is not greater than 8 digit
    </span>
    </span>
    </form>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM