

The difference is that the oninput event occurs immediately after the value of an element has changed, while onchange occurs when the element loses focus. Tip: This event is similar to the oninput event. The onchange attribute fires the moment when the value of the element is changed. If validate() function returns true the form will be submitted otherwise it will not submit the data. Here we are calling a validate() function before submitting a form data to the webserver. Here is simple example showing its usage. So you can put your form validation against this event type. This event occurs when you try to submit a form. onSubmitĪnother most important event type is onsubmit. This will produce following result and when you click Hello button then onclick event will occur which will trigger sayHello() function. You can put your validation, warning, etc. This is the most frequently used event type which occurs when a user clicks mouse left button. In JavaScript, using the addEventListener() method: object.addEventListener("blur", myScript) Sanity checking of the data being submitted can be performed on the client side using this event. OnSubmit: this is an important event that is raised when the submit button on an HTML form is clicked to submit the form data to the web server. OnSelect: this event, as its name implies, is raised when some tex in a text box or text area is selected.

OnFocus: thisevent is raised when a select, text or textarea items is selected on an HTML form. OnClick: this event is raised when the user clicks the user clicks on an object, for example: button, image, hyperlink, etc. OnChange : this event is raised when the text in a select, text, or textarea form item is altered by the user.

In other words, when the item losses focus the onBlur event is raised. OnBlur: this event is raised when a select, text, or textarea form item is acted upon and then moved off of by the user. To totally unlock this section you need to Log-inīesides the mouse and keyboard events, there are more events available in JavaScript, which we are going to discuss in this article:
