Javascript DOM HTML Input URL disable and enable

Introduction

Disable and enable a URL field:

elements with type="url" are not supported in Safari.

View in separate window

<!DOCTYPE html>
<html>
<body>

Homepage: <input type="url" id="myURL"><br><br>

<button onclick="disableBtn()">Disable URL Field</button>
<button onclick="enableBtn()">enable URL Field</button>
<script>
function disableBtn() {//w  w w  .j  a  va 2 s  .  c  o  m
  document.getElementById("myURL").disabled = true;
}
function enableBtn() {
  document.getElementById("myURL").disabled = false;
}
</script>

</body>
</html>



PreviousNext

Related