I know his question has been answered in the site, but i have some conflict with my current code that i've used. (find it below)
I have default value in my text filed "example.company.com
" and i set the focus to clear the example
from the value.
jQuery(document).ready(function() {
jQuery.fn.cleardefault = function() {
return this.focus(function() {
if( this.value == this.defaultValue ) {
this.value = ".company.com";
}
}).blur(function() {
if( !this.value.length ) {
this.value = this.defaultValue;
}
});
};
jQuery(".clearit input, .clearit textarea").cleardefault();
});
I also need to set the cursor to the beginning of the line when user clicks and the example
disappeared, but i wasn't able to do that. I'm not very expert in jQuery, so asking here to get help.
Thanks!