Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable direct value editing in input type="number"

i have using<input type="number">. in that i don't want user can enter manually numbers in to input. user only increase and decrees numbers by step then is it possible.

like image 217
Devang Kateliya Avatar asked Jun 24 '14 07:06

Devang Kateliya


Video Answer


2 Answers

You can do it by cancelling the keydown event. Either inline (<input type="number" onkeydown="return false">), or within an event handler.

like image 54
blockhead Avatar answered Oct 03 '22 03:10

blockhead


Use jQuery

$('input[type="number"]').keydown(function (e) {
  e.preventDefault();
});
like image 37
Sridhar R Avatar answered Oct 03 '22 02:10

Sridhar R