The disabled property disables or enables a keygen field.
Keygen disabled |
Yes | No | Yes | Yes | Yes |
Return the disabled property.
keygenObject.disabled
Set the disabled property.
keygenObject.disabled=true|false
Value | Description |
---|---|
true|false | Disable or enable a keygen field
|
A Boolean type value, true if the keygen field is disabled, otherwise false.
The following code shows how to check if a keygen field is disabled.
<!DOCTYPE html>
<html>
<body>
Encryption: <keygen id="myKeygen" name="security" disabled>
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {<!-- w w w .jav a 2s. c om-->
var x = document.getElementById("myKeygen").disabled;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
The code above is rendered as follows:
The following code shows how to disable and enable a keygen field.
<!DOCTYPE html>
<html>
<body>
<!--from w ww . java 2 s . c o m-->
<form action="demo_keygen.asp" method="get">
Username: <input type="text" name="usr_name">
Encryption: <keygen id="myKeygen" name="security">
<input type="submit">
</form><br>
<button onclick="disableKey()">Disable Keygen field</button>
<button onclick="undisableKey()">Enable Keygen field</button>
<script>
function disableKey() {
document.getElementById("myKeygen").disabled = true;
}
function undisableKey() {
document.getElementById("myKeygen").disabled = false;
}
</script>
</body>
</html>
The code above is rendered as follows: