Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

add fraction in angular

@Directive({
   selector: '[exampleDirective]'
})
export class TestDirective {

   constructor() {}

   @HostListener('input', ['$event'])
   ngOnChanges(evt: any) {
      const pattern: RegExp = new RegExp(/^[0-9]+.?[0-9]*$/);
      if (!pattern.test(evt.target.value)) {
         evt.srcElement.value = evt.srcElement.value.substring(0, evt.srcElement.value.length - 1); // this will erase the last char that does not match the pattern...
      }
   }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript set elements width by tag name 
Javascript :: reset regex javascript 
Javascript :: Authomatically set an environment variable from response in postman 
Javascript :: extend current date with 30 days in jquery datepicker 
Javascript :: sequelize find result as raw json 
Javascript :: using filter and pipe in rxjs 
Javascript :: remove property from object javascript 
Javascript :: mongoose sort 
Javascript :: get selected option from select javascript 
Javascript :: babel compile files empty 
Javascript :: javascript encrypt decrypt 
Javascript :: get time in google apps script 
Javascript :: what is useref in react 
Javascript :: slideshow react npm 
Javascript :: decrementar en java 
Javascript :: make id of certain length js 
Javascript :: play a sound in js 
Javascript :: vue not loading env variables 
Javascript :: ios safari controls cover element 
Javascript :: search an array with regex javascript find 
Javascript :: javascript find area of triangle 
Javascript :: react-native-dropdown-picker for form react native 
Javascript :: react native elements bottom sheet 
Javascript :: find when webpage was last updated js 
Javascript :: codeceptjs "waitForClickable" 
Javascript :: export to excel on button click in javascript 
Javascript :: request-promise-native error RequestError: Error: unable to verify the first certificate 
Javascript :: get parent class javascript 
Javascript :: jquery connection reset 
Javascript :: update array usestate 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =