Support » Themes and Templates » function for putting label inside input field in forms

  • Resolved mellyg

    (@mellyg)


    Hey there

    I am wanting to put the labels inside the input fields, I have found a website with the code to this but I am not sure what to do with the javasript.

    Here is a link to the code http://attardi.org/labels/#javascript

    Does the javascript need something added to make it work in the functions.php file, at the moment when I paste it in it comes up full off errors.

    Mel

Viewing 5 replies - 1 through 5 (of 5 total)
  • Orbmix

    (@orbmix)

    Hi mellyg,

    I think if you want to put the labels inside the input fields. you can try this with simple html and simple JavaScript

    <input type=”text” name=”unsername” onfocus=”if(this.value==’Your message here‘)this.value=”” onblur=”if(this.value==”)this.value=’Your message here‘”/>

    may be you understand above the code if you need more i can help you.

    Orbmix

    mellyg

    (@mellyg)

    Thanks for the reply – the only problem I had with that code was that the label didn’t show up untill the mouse was clicked inside the form. I got it to work with:

    <p><label for=”your-name” class=”label-hidden”>Your Name (required)</label>
    [text* your-name watermark “Your name (required)”]</p>

    Many thanks for your help.

    mellyg

    (@mellyg)

    Hi so I am trying to also insert the label into the input field into the mailchimp sign up form but having trouble. Does anyone know how I need to change the code below

    [ Moderator note: please wrap code in backticks or use the code button. ]

    <div class="mc-field-group">
    	<label for="mce-LNAME">Last Name </label>
    	<input type="text" value="" name="LNAME" class="" id="mce-LNAME">
    </div>
    	<div id="mce-responses" class="clear">
    		<div class="response" id="mce-error-response" style="display:none"></div>
    		<div class="response" id="mce-success-response" style="display:none"></div>
    	</div>	<div class="clear"><input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe"></div>
    </form>
    </div>
    Orbmix

    (@orbmix)

    <div class="mc-field-group">
    	<label for="mce-LNAME">Last Name </label>
    	<input type="text" value="<strong>Last Name"</strong> name="LNAME" class="" id="mce-LNAME">
    </div>
    	<div id="mce-responses" class="clear">
    		<div class="response" id="mce-error-response" style="display:none"></div>
    		<div class="response" id="mce-success-response" style="display:none"></div>
    	</div>	<div class="clear"><input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe"></div>
    </form>
    </div>
    Orbmix

    (@orbmix)

    Use the code placed in input field vales=”last name”

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘function for putting label inside input field in forms’ is closed to new replies.