Disable and enable a number field:
<!DOCTYPE html> <html> <body> <input type="number" id="myNumber" value="2"><br><br> <button onclick="disableBtn()">Disable Number Field</button> <button onclick="enableBtn()">enable Number Field</button> <script> function disableBtn() {// w w w . j a v a2s .co m document.getElementById("myNumber").disabled = true; } function enableBtn() { document.getElementById("myNumber").disabled = false; } </script> </body> </html>