itzasifmirza
10/23/2017 - 3:17 PM

On input keyup check is string or integer using lodashjs.

This is used to check if user input any wrong character, if its ingetger field and you want to restrict user not to write any string in it. it use lodashjs very simple.

input field its used in ionic

<ion-input type="text" [(ngModel)]="ccid" (ionChange)="getItems($event)"></ion-input>

  getItems(ev) {
    _.map(_.split(ev.value, ''), function(item){
      if(_.inRange(item, 0, 9) == false){
        console.log('nan');
      }
    });
  }