WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] function for putting label inside input field in forms (6 posts)

  1. mellyg
    Member
    Posted 11 months ago #

    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

  2. Orbmix
    Member
    Posted 11 months ago #

    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

  3. mellyg
    Member
    Posted 10 months ago #

    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.

  4. mellyg
    Member
    Posted 10 months ago #

    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>
  5. Orbmix
    Member
    Posted 10 months ago #

    <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>
  6. Orbmix
    Member
    Posted 10 months ago #

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

Reply

You must log in to post.

About this Topic