Open In App

HTML DOM Keygen form Property

Improve
Improve
Like Article
Like
Save
Share
Report

The Keygen form property in HTML DOM is used to return the reference of the form containing the keygen element. It is a read-only property and returns the form object on success.

Syntax:

keygenObject.form

Return Value: It returns a reference to the form element containing the keygen element. It returns NULL if the keygen is not in the form.

Example: This example shows the working of the Keygen form property.

HTML




<!DOCTYPE html>
<html>
 
<head>
    <style>
        h1 {
            color: green;
        }
 
        h2 {
            font-family: Impact;
        }
 
        body {
            text-align: center;
        }
    </style>
</head>
 
<body>
    <h1>GeeksforGeeks</h1>
 
    <h2>HTML DOM Keygen form Property</h2>
    <br>
     
    <form id="myGeeks">
        Username:
        <input type="text" name="uname">
        <br><br> Encryption:
        <keygen id="Geeks" form="myGeeks"
            name="secure" autofocus>
        <input type="submit">
    </form>
 
    <button onclick="My_form()">
        Return
    </button>
 
    <p id="test"></p>
 
 
     
    <script>
        function My_form() {
            var d = document.getElementById("Geeks").form.id;
            document.getElementById("test").innerHTML = d;
        }
    </script>
</body>
 
</html>


Output:

Supported Browsers:

  • Google Chrome
  • Opera
  • Firefox
  • Apple Safari


Last Updated : 01 Apr, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads