Header Ads

Alphabets Only Directives

AlphaOnly Directives

This only allows the alphabets in the input box. use this directive to block other than alphabets in this functionalities

Add the directives name inside the input field

<input type = "text" name="name" alphaOnly >

Save these directives and name it as allowalphaOnly

   @HostListener('keyup'['$event']) onKeyUp(event) {
        let value = this. eleRef.nativeElement.value;
        value = this. functionCall(value);
        this. eleRef.nativeElement.value = value;

   @HostListener('paste'['$event']) onPaste(event) {

        this. eleRef.nativeElement.value 
         this.functionCall(_.replace(this. eleRef.nativeElement.value/[^a-zA-Z0-9 ]/g''));

    functionCall(value) {
       value = _.replace(value/^\s/g'');
       value = _.replace(value/[^a-zA-Z]/g'');

       return value;

Post a Comment