Disable a URL field:
document.getElementById("myURL").disabled = true;
Click the button to disable the URL field.
elements with type="url" are not supported in Safari.
<!DOCTYPE html> <html> <body> Homepage: <input type="url" id="myURL"> <button onclick="myFunction()">Test</button> <script> function myFunction() {/*from www . j ava2 s . co m*/ document.getElementById("myURL").disabled = true; } </script> </body> </html>
The disabled property sets or gets whether a URL field should be disabled, or not.
This property mirrors the HTML disabled attribute.
Property Values
Value | Description |
---|---|
true | The URL field is disabled |
false | Default. The URL field is not disabled |
The disabled property returns true if the URL field is disabled, otherwise it returns false.