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



Return Value

A reference to the form element containing the keygen field.


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

<!DOCTYPE html>
<!--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">
<button onclick="myFunction()">test</button>

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

function myFunction() {
    var x = document.getElementById("myKeygen");
    document.getElementById("demo").innerHTML = x;


The code above is rendered as follows: