Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

HTML DOM Keygen form Property

  • Last Updated : 05 Oct, 2021

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:

Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.

keygenObject.form

Return Value: It returns a reference to the form element containing the button. 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



My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!