UNPKG

phone-check-egypt

Version:

its a directive that gibe validation on mobile number using regex format .. # directive requirements :

2 lines 2.35 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core")):"function"==typeof define&&define.amd?define("phone-check-egypt",["exports","@angular/core"],t):t(e["phone-check-egypt"]={},e.ng.core)}(this,function(e,t){"use strict";var n=function(){function e(){}return e.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ctorParameters=function(){return[]},e.ngInjectableDef=t.defineInjectable({factory:function(){return new e},token:e,providedIn:"root"}),e}(),r=function(){function e(){}return e.prototype.ngOnInit=function(){},e.decorators=[{type:t.Component,args:[{selector:"enl-phone-check-egypt",template:"\n <p>\n phone-check-egypt works!\n </p>\n ",styles:[]}]}],e.ctorParameters=function(){return[]},e}(),o=function(){function e(e){this.el=e,this.regex=/^[0]{1}[1]{1}[1|2|5|0]{1}[0-9]{8}$/g,this.specialKeys=["Backspace","Tab","End","Home"],this.el.nativeElement.required&&this.el.nativeElement.insertAdjacentHTML("afterend",'\n<div class="invalid-feedback">* Please Enter valid phone number.</div>')}return e.prototype.onKeyDown=function(e){if(-1===this.specialKeys.indexOf(e.key)){var t=this.el.nativeElement.value.concat(e.key);""!=t||t!=undefined||null!=t?t&&t.length<this.el.nativeElement.max?this.el.nativeElement.classList.remove("is-invalid"):t&&t.length==this.el.nativeElement.max?1==this.regex.test(t)?this.el.nativeElement.classList.remove("is-invalid"):(this.el.nativeElement.classList.add("is-invalid"),this.formData.form.controls[this.el.nativeElement.name].setErrors({incorrect:!0})):t&&t.length>this.el.nativeElement.max&&e.preventDefault():(this.el.nativeElement.classList.add("is-invalid"),this.formData.form.controls[this.el.nativeElement.name].setErrors({incorrect:!0}))}},e.decorators=[{type:t.Directive,args:[{selector:"[OnlyNumber]"}]}],e.ctorParameters=function(){return[{type:t.ElementRef}]},e.propDecorators={formData:[{type:t.Input,args:["formData"]}],onKeyDown:[{type:t.HostListener,args:["keydown",["$event"]]}]},e}(),i=function(){function e(){}return e.decorators=[{type:t.NgModule,args:[{imports:[],declarations:[r,o],exports:[r]}]}],e}();e.PhoneCheckEgyptService=n,e.PhoneCheckEgyptComponent=r,e.PhoneCheckEgyptModule=i,e.OnlyNumberDirective=o,Object.defineProperty(e,"__esModule",{value:!0})}); //# sourceMappingURL=phone-check-egypt.umd.min.js.map