Javascript examples for DOM HTML Element:Input Number
Allow numbers and minus sign only in input box via input action handler
<html lang="en"> <head> <title> kecer</title> </head> <body translate="no"> <input id="num" type="text"> <script> var last = ''; var input = document.getElementById('num'); input.addEventListener('input', function(e){ if (isNaN(e.target.value))// ww w . ja v a 2 s. c om e.target.value=last; else last=e.target.value; }); </script> </body> </html>