Good all the time of day.

Imagine there is an authorization form on the site, input'y for login / password. From above it is written - where to enter something. How to do, what would the input'ov value that the field was already inside, and when you put the cursor there - disappeared and if the input'y not filled, and pressed the send button, then the values ​​that are transmitted were empty?

PS This is not a value.

  • 7
    (whisper) is a placeholder. google it - Yura Ivanov

5 answers 5

Look here: a hint for a form field .

  • because cross browser friendly, accept this answer. - sergey

There is an attribute in html placeholder . Try to use it.
Cons: It is not supported by IE and old browsers (Mozila <4.0, Opera <11.0, Safari <5.0)

     <input id="1" value="text" onmouseover="document.getElementById('1').value = ' ';" onmouseout="document.getElementById('1').value = 'text';"> 
    • It is also an option. so even less code! - sergey

    No onmouseover and onmouseout

     <input id="1" value="text" onfocus="if (this.value == 'подсказка') this.value = '';" onblur="if (this.value == "") this.value = 'подсказка';" /> 
    • It will not work, because It is necessary to have a standard value, i.e. value, but in this case, when sending, the fields will not be empty. (Condition of the question) - Node_pro
      <script type='text/javascript'> var objSearch = document.getElementById('front_search_query'); objSearch.onfocus = function() { if(objSearch.value=='Поиск') objSearch.value = '';} objSearch.onblur = function() { if(objSearch.value=='') objSearch.value = 'Поиск';} </script>