A form event is fired when a form control receive or loses focus or when the user modify a form control value such as by typing text in a text input, select any option in a select box etc. Here're some most important form events and their event handler.
This event occurs when an element gets focused on a web page. The onfocus
event handler is used to handle this event. The following example will highlight the background of text input in green color when it receives the focus.
This event occurs when the user takes the focus away from a form element. The onblur
event handler is used to handle this event.
The following example will show you an alert message when the text input element loses focus.
Note: First click inside the text input box then click outside to see how it works.
This event occurs when the value of a form element is changed. The onchange
event handler is used to handle this event.
This example will show you an alert message when you change the option in the select box.
Note: Select any option in select box to see how it works.
The submit event occurs when the submit button is clicked. The onsubmit
event handler is used to handle this event.
The following example will show you an alert message while submitting the form to the server.
List of color names supported by all browser »
List of character codes to display special character »
List of all language supported by all browser »
List of Country code supported by all browser »