Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

html5 search input events

What event is triggered when a user clicks the X in a search input field (in webkit browsers) to cancel the search or clear the text?

Information is available about restyling the button and other custom events, but not on using this button.

like image 808
jmilloy Avatar asked Apr 06 '11 20:04

jmilloy


People also ask

Which event occurs when an HTML input field was changed?

The input event fires when the value of an <input> , <select> , or <textarea> element has been changed. The event also applies to elements with contenteditable enabled, and to any element when designMode is turned on.

What is input event in HTML?

The oninput event occurs when an element gets user input. This event occurs when the value of an <input> or <textarea> element is changed.

How will you get text inside an input tag event?

Answer: Use the value Property You can simply use the value property of the DOM input element to get the value of text input field. The following example will display the entered text in the input field on button click using JavaScript.

What is input type search?

<input type="search"> <input> elements of type search are text fields designed for the user to enter search queries into. These are functionally identical to text inputs, but may be styled differently by the user agent.


1 Answers

The onsearch event is triggered both when the search input is submitted and when the user clears the search.

<input type=search onsearch="javascript:alert('SEARCH: ' + this.value);" />
like image 187
jmilloy Avatar answered Sep 28 '22 05:09

jmilloy