My textfields display instructions as default values within the textbox. When focused, the text color lightens but only disappears when text is entered. If text is erased, the label reappears. I'm proud of this feature because it's quite seamless. A generic default value just doesn't cut it here, as they disappear on focus.
I have managed to make it work, however, the code has become complex due to negative margins that correspond to individual textfield widths. Ideally, I want a dynamic solution where each label for its corresponding textfield is automatically positioned without intricate coding, likely using a script.
I would greatly appreciate any assistance with this issue but please note I am not interested in default values as a resolution.
Thank you.
Mike
Revised for clarity.
An updated edit includes some simple code showcasing the desired effect:
<input style="position: relative; width: 150px; font-size: 10px; font-family: Verdana, sans-serif; " type="text" name="name" id="name"
onfocus="javascript: document.getElementById('nameLabel').style.color='#BEBEBE';"
onkeypress="javascript: if (event.keyCode!=9) {document.getElementById('nameLabel').innerHTML=' ';}"
onkeyup="javascript: if (this.value=='') document.getElementById('nameLabel').innerHTML='Your Name';"
onblur="javascript: if (this.value=='') {document.getElementById('nameLabel').style.color='#7e7e7e'; document.getElementById('nameLabel').innerHTML='Your Name';}"/>
<label id="nameLabel" for="name" style="position: relative; margin-left: -150px; font-size: 10px; font-family: Verdana, sans-serif;">Your Name</label>