HTML DOM Input Search name Property

HTMLWeb DevelopmentFront End Technology

The HTML DOM Input Search name property is used for setting or returning the name attribute of a reset button. The name attribute helps in identifying the form data after it has been submitted to the server. JavaScript can also use the name attribute to refer form elements for manipulating later on.


Following is the syntax for −

Setting the name property − = name

Here, name is for specifying the search field name.


Let us look at an example for the Search name property −

<!DOCTYPE html>
<h1>Input search name Property</h1>
FRUITS: <input type="search" id="SEARCH1" name="fruits" maxlength="5">
<p>Change the name of the above search field by clicking the below button</p>
<button type="button" onclick="changeName()">CHANGE NAME</button>
<p id="Sample"></p>
   function changeName() {
      document.getElementById("SEARCH1").name ="SEARCH_2 ;
      document.getElementById("Sample").innerHTML = "Search field name is now SEARCH_2";


This will produce the following output −

On clicking the CHANGE NAME button −

Updated on 19-Aug-2019 09:57:00