"Substitute" ideal for placeholder

1

I'm in the final stages of a project! And now I'm doing the tests like performance tests and structuring errors! One of the errors found is placeholder of inputs and textarea. What can I use in place of the placeholder and which preferably not error at the time of validation?

    
asked by anonymous 01.05.2015 / 02:00

1 answer

2

Switch your document to HTML5 by simply changing the doctype at the beginning of the file to <!doctype html> .

<!doctype html>
<html>
  <!-- head -->
  <body>
     <input type='text' name='foo' placeholder='foo'>
  </body>
</html>

If this is not possible in your project, you can then choose to use Javascript to create the same effect as the placeholder attribute:

<input type='text' value='foo'
       onfocus="if (this.value === 'foo') {this.value = '';}"
       onblur="if (this.value === '') {this.value = 'foo';}">

The second option gives a bit more work, it is not simply checking if the value of the field is "foo" (which was just an example). In this case, using a plugin to do this might be the best solution, for example Placeholder.js .

    
01.05.2015 / 14:50