Tryit<!DOCTYPE html><html><head><title>Wikitechy onsearch attribute</title></head><body><p>Type something in the Searchbar and press "ENTER".</p><input type="search" onsearch="onSearch(this.value)"><script>
function onSearch(val) {
alert("You are searching for : " + val);
}
</script></body></html>
Code Explanation for onsearch Attribute in HTML:
The onsearch attribute is used to call onSearch() JavaScript function when the user search something in the search bar.
The JavaScript function onsearch is used to display an alert message.
Output for onsearch Attribute in HTML:
The name Wikitechy is typed in the search bar.
After pressing the Enter button then the alert box is open with the message “You are searching for : wikitechy“.