Javascript Reference - HTML DOM Keygen form Property








The read only form property gets the form that contains the keygen field.

Browser Support

Keygen form Yes No Yes Yes Yes

Syntax

keygenObject.form 

Return Value

A reference to the form element containing the keygen field.





Example

The following code shows how to get the id of the form containing the <keygen> element.


<!DOCTYPE html>
<html>
<body>
<!--from  w w w .ja  v  a 2s. c  o m-->
<form id="myForm" action="demo_keygen.asp" method="get">
  Username: <input type="text" name="usr_name">
  Encryption: <keygen id="myKeygen" name="security">
  <input type="submit">
</form>
<button onclick="myFunction()">test</button>

<p id="demo"></p>

<script>
function myFunction() {
    var x = document.getElementById("myKeygen").form.id;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The code above is rendered as follows: