showing results for - "numeric key angular validation"
Amélie
24 Mar 2018
1import { Directive, ElementRef, HostListener, Input } from '@angular/core';
2import { NgControl } from '@angular/forms';
3
4@Directive({
5  selector: 'input[type=number], input[numbersOnly]'
6})
7export class NumbersOnlyInputDirective {
8
9  constructor(private elRef: ElementRef) { }
10
11  @HostListener('input', ['$event']) onInputChange(event) {
12    const initalValue = this.elRef.nativeElement.value;
13    this.elRef.nativeElement.value = initalValue.replace(/[^0-9]*/g, '');
14    if ( initalValue !== this.elRef.nativeElement.value) {
15      event.stopPropagation();
16    }
17  }
18
19}
queries leading to this page
allow only numbers in input tsangular input accept only numbersnumeric key angular validationtext only directiveallow only number input angularangular input with only input numbersangular form accept only number directivenumber only directiveensure text field is only number angularinput angular numerichow to accept only integer value and float value in angular input box parrtenstring number only input html angularangular numeric inputmat input whole number onlyallow only numbers in textbox angular 10angular 5 input allow only numbersdon 27t allow e in number input using regular expression in angularangular 7 input number onlyonly allow digit in angular 7numbers in angular directivesnumeric fields for mobile digit only angular 4angular 9 input only numbersmat input number 2 digit pattern htmlonly numeric field in angularangular only allow numbers in inputinput field to accept only numbers angular 6angular 6 only allow numbers in input reactive forms angular directive for number validationallow number only angularangular onlynumber what isinput text only numbers angularangular directive for numbers onlyangular 6 only allow numbers in inputhow to enter numbers onlty in textbox angularforce tel field to only allow numbers in angularinput accept only numbers angularangular 2 allow only numbers and one dot siteangular directive to accept number and 2 alphabetsallow only numbers in input angular 10allow numbers only in textbox angularangular numeric field onlykeypress validation directive in angular 6input number angular 8number only directive angularangular digit only inputangular numbers only directiveinput angular number onlyget only numeric in angular 6numbers only directive in angularinput type 3dtext only numbers angular 8accept only numeric values text field angularangularts only allow numbers in inputangular 8 regex only numberangular directive to accept only numberson keydown accept only numbers angular 8angular don 27t allow letters in inputonly numbers not allow angular 8only allow number and letter angular inputinput accept only numbers directive angularangular directive to allow only numbersregular expression to input integer only in html number field angularangular input type text only number directiveangular input type number onlyonly number directive angularonly phone number inputangularhow to allow only pattern in input angularmat input allow only letters angular 8angular pipe to accept number only in the rangenumber only directive angular 4angular onlynumberangular input text only numberseven only allow numbers in input regex angularinput allow only numbers angular 6numbers only validation angular 4angular only number inputangular input text onlangular only accept integer no decimalangular 4 directive to allow only numbersangular directive only numbersnumber directive angular 6app text input put only number angualrallow only numbers in input type text in angular 8angular allow only numbers inputangular seven only allow numbers in input regexangular input number onlyallow only numbers in angularangular 2 allow only numbers and one dot inputangular directive numbers onlyonly english chrachter and number directive angularnumbers only angulardont allow to enter more than 6 digits in input angular reaqctive formangular text allow only number to typeapp numbers only angular directivematinput allow only numbersangular form input number onlyangular input text onlycustom directive to only allow regex pattern in input field angularangular directive to allow only 4 numbersonlynumber directive angulardirective number angularhow to check if only number is entered in the txt box angularget only numeric in angular 6 in inputonly numbers angular inputdont allow 1 in number angularinput field only numbers angularhow to show only numbers angularmake a field in angular numeric onlyangular directiive only numbersangular input only integersonly number input text angular 10allow only numbers directive angularallow only at the beginning of a number angularangular 6 input number onlyangular 8 input text onlyangular force numbericangular 8 input text only numberhtml input field take number only angularangular directive accepts integernumbers only directive angular 6numeric key angular validation