---
title: "What is the new feature in HTML 5 Form Events"  
description: "What are the new features in the HTML5 form eventWhen a user visits a website, they do things like click on text and images and given links, hover o"  
author: "Anonymous User"  
published: 2011-07-22  
updated: 2020-07-08  
canonical: https://www.mindstick.com/articles/580/what-is-the-new-feature-in-html-5-form-events  
category: "html5"  
tags: ["html5"]  
reading_time: 3 minutes  

---

# What is the new feature in HTML 5 Form Events

## What are the new features in the HTML5 form event

When a user visits a [website](https://yourviews.mindstick.com/view/87705/when-do-we-require-an-agency-to-drive-traffic-to-a-website), they do things like click on text and images and given links, hover over things, etc. That is some examples of what [JavaScript](https://www.mindstick.com/articles/874/how-to-create-watermark-text-for-textbox-by-using-javascript) calls events. Events triggered by actions inside an HTML form. Events are an action performed by the user by clicking a mouse.\

New Form events [attribute](https://www.mindstick.com/blog/61/ado-dot-net-object-model-and-attributes)

#### OnContextMenu

Fires when the [user clicks](https://answers.mindstick.com/qa/34556/if-a-user-clicks-all-the-google-ads-on-my-site-is-it-foul) the right button of the mouse in the client area, opening the context menu and script to be run when a context menu is triggered.

##### Code:

```
<head>     <title></title>       <script language="JavaScript" type="text/javascript">         function oncontextmenuexample() {            alert("This image is copyrighted") //Script will run when context menu is triggered         }     </script></head><body >     <p>         Right click in the image.</p>     <img oncontextmenu="oncontextmenuexample();return false;" src="Penguins.jpg" alt="" width="99" height="76"></body>
```

If a user wants to copy this image and if user click right button of the mouse then a message will show on the page as shown below:

##### Screenshot

![HTML 5 Form Events](https://www.mindstick.com/mindstickarticle/769beaa0-943c-4799-8295-7de426d6b9a1/images/1331f5b6-d9a5-4ec5-9642-e257dc2eb24e.png)

#### on-form-change

It is a new HTML5 event fires each time an element value in your form changes. It very useful for [instances](https://answers.mindstick.com/qa/92508/how-can-you-hide-the-sql-server-instances) where you need to perform an action when the user makes a [selection](https://www.mindstick.com/blog/60/populate-records-in-second-listbox-according-to-the-selection-in-first-list-box) or enters a value.

```
<head>     <title></title>       <script type="text/javascript">         function input() {//Script to be run when a form changes            var textvalue = document.getElementById("t1").value;  //storing textbox value in variable            document.getElementById("Text1").value = textvalue//displaying value in another textbox where id is Text1         }     </script>  </head><body>     <form onformchange="input()">     <h3>Example of onformchange</h3>     <table width="300">         <tr>            <td>                Enter Some text:            </td>            <td>                <input type="text" id="t1" />            </td>         </tr>         <tr>            <td>                After event occured            </td>            <td>                <input type="text" id="Text1" />            </td>         </tr>     </form></body>
```

If the user enters text in the [textbox](https://www.mindstick.com/articles/320/textbox-control-in-vb-dot-net) then he selects or clicks on the page then on_form_change event will invoke as shown below:

![HTML 5 Form Events](https://www.mindstick.com/mindstickarticle/769beaa0-943c-4799-8295-7de426d6b9a1/images/25b573e5-988a-4294-acc6-bf207d15dc96.png)

## onforminputNew

This one is also a new HTML5 event. It fires when any form element's input

\

changes.

```
<title></title>       <script type="text/javascript">         function add() {//Script to be run when a form gets user input            var a = document.getElementById("a").value;            var b = document.getElementById("b").value;            document.getElementById("l1").innerHTML = Number(a) + Number(b);//adding value and displaying in label         }     </script>  </head><body>     <form onsubmit="return false">     <input id="a" name="a" type="number" step="any">    +     <input id="b" name="b" type="number" step="any">    =     <output onforminput="add()"></output>     <label id="l1"></label>     </form></body>
```

When user will give input then addtion [operation](https://yourviews.mindstick.com/view/83916/why-is-it-necessary-to-sterilize-operation-theater) will perform as shown below:

![HTML 5 Form Events](https://www.mindstick.com/mindstickarticle/769beaa0-943c-4799-8295-7de426d6b9a1/images/cc19db17-50b5-4c1e-9d4a-79b45bb89479.png)

#### OnInput

This occurs when the text [content of an element](https://www.mindstick.com/forum/158663/what-is-the-css-property-to-specify-the-space-between-the-content-of-an-element-and-its-border) is changed through the [user interface](https://www.mindstick.com/blog/302016/what-is-user-interface-and-what-are-its-benefits).

```
<head>     <title></title>     <head>         <script type="text/javascript">            function input() {//Script to be run when an element gets user input                var textvalue = document.getElementById("t1").value;//storing textbox value in variable                document.getElementById("l1").innerHTML = textvalue//displaying value in label where id is l1            }         </script>       </head>     <body>         Enter some characters into the text field!         <input type="text" oninput="input()" id="t1" /><br /> <!--using oninput attribute in input element-->         <br />         <label id="l1">         </label>    </body>                 
```

If a user will give any input to textbox all text will be shown on the page below the textbox

as shown below:

![HTML 5 Form Events](https://www.mindstick.com/mindstickarticle/769beaa0-943c-4799-8295-7de426d6b9a1/images/f108888a-75b5-4cf3-809f-eae43ce2206b.png)

---

Original Source: https://www.mindstick.com/articles/580/what-is-the-new-feature-in-html-5-form-events

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
