+ 1

How to take input in JavaScript in only numeric format??

How to take input in JavaScript in numeric format only and not in alphabets or any other format like in HTML, we can take inputs in number only i.e.: <input type="number">

4th Jun 2019, 12:12 AM
ApidBoy
ApidBoy - avatar
1 Resposta
+ 5
No. The direct way to input in JavaScript is prompt() function. For getting number from input, try this way. var a = prompt("Enter a number"); a = parseInt(a,10); //10 is radix alert(a+1);
4th Jun 2019, 1:43 AM
Sarthak Pokhrel
Sarthak Pokhrel - avatar