Dino
Dino

Reputation: 402

How to disable input on type="number" but only keep spinners usable

So I need to disable input on:

<input type="number" name="name" value="0" min="0" max="1" />

But keep the spinners working... to avoid some input anything above or beneath min and max.

Upvotes: 0

Views: 825

Answers (1)

ryeballar
ryeballar

Reputation: 30088

You can use jquery for this task:

DEMO

HTML

<input type="number" name="name" value="0" min="0" max="1" />

JAVASCRIPT (JQUERY)

$('input[type="number"]').keydown(function(e) {
  e.preventDefault();
});

Upvotes: 2

Related Questions