Today I came across a form using inline javascript events for placeholders:
<div class="inputBG" align="center"><input name="company" id="company" type="text" placeholder="Company Name" onBlur="if (this.value == '') {this.value = 'Company Name';}" onFocus="if (this.value == 'Company Name') {this.value = '';}" /></div>

This is a no-no.
Instead, use this:
HTML
<input id="name" type="text" name="name" placeholder="placeholder name" />

 jQuery
$(document).on('load', function(){
$('input[type=text]').each(function(i,v){
// set initial values
$(this).val($(this).attr('placeholder'));
});
}
$('input').on('click',function(){
if($(this).val() == $(this).attr('placeholder')){ $(this).val(''); }
});

And all is good and right in the world.
I'm assuming you have a basic understanding of document structure and how to implement jQuery.
If you have any questions, please ask.

Similar Posts