Reputation: 1
i want to do so then a person click on the input box it should hide the standard "custom" text
i have this
echo form_input('username', 'Username', 'class="login_input"');
how can i do with javascript that username get remove then clicked?
Thanks
Upvotes: 0
Views: 1742
Reputation: 503
Try this
echo form_input('username', 'Username', 'class="login_input" onblur="if (this.value == \'\') {this.value = \'Custom\';}" onfocus="if (this.value == \'Custom\') {this.value = \'\';}" value="Custom"');
Upvotes: 0
Reputation: 2288
This way, both onfocus and onblur event will work
//script tag starts function myFocus(element) { if (element.value == element.defaultValue) { element.value = ''; } } function myBlur(element) { if (element.value == '') { element.value = element.defaultValue; } } //script tag ends echo form_input('username', 'Username', 'class="login_input" onfocus="myFocus(this);" onblur="myBlur(this);" ');
Upvotes: 3
Reputation: 21541
Try:
echo form_input('username', 'Username', 'class="login_input" onfocus="this.value=\'\'"');
Upvotes: 1