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
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);" ');
Try:
echo form_input('username', 'Username', 'class="login_input" onfocus="this.value=\'\'"');