0

I have next input

<input type="number" name="min" ng-model="vm.item.min" ng-max="vm.item.max" required >

But I can type string data here (in Edge Browser). How can i fix it?

TylerH
  • 20,799
  • 66
  • 75
  • 101
John Doe
  • 3,794
  • 9
  • 40
  • 72

1 Answers1

2
window.addEventListener("input",function(e){
    e.target.value=parseFloat(e.target.value)||0;
});

A js solution. Whenever theres some input, replace the value with the Number representation of it... http://jsbin.com/xisamadene/edit?output

Change "input" to "change" if you want the replacement to appear when the user leaves the element

Jonas Wilms
  • 132,000
  • 20
  • 149
  • 151