Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1006587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:29:06+00:00 2026-05-16T08:29:06+00:00

I’ve been asked to place a form on our website, simple you might think,

  • 0

I’ve been asked to place a form on our website, simple you might think, but this one has some cool little js in place to make the label for the input sit inside it, clever but for some reason not working as intended on my page.

It doesn’t place the label inside the Input field.
It uses the JS to place the label and CSS for the color changes and such.

Here is a jsFiddle example.

And here is the live example.

Thanks anyone for any help 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T08:29:07+00:00Added an answer on May 16, 2026 at 8:29 am

    although you can do it, this is not ideal. there’s a perfectly valid way forward via a HTML5 input improvement known as ‘placeholder’.

    a while back I wrote a placeholder=”” class for mootools that is basically, a progressive enhancement for browsers that lack HTML5 placeholder capabilities (at the time of writing, anything that’s not webkit)

    http://fragged.org/mooplaceholder-input-placeholder-behaviour-class_1081.html

    the fiddle: http://jsfiddle.net/hFtNd/1/

    the class itself:

    var mooPlaceholder = new Class({
        // behaviour for default values of inputs class
        Implements: [Options],
    
        options: {
            // default options
            htmlPlaceholder: "placeholder", // the element attribute, eg, data-placeholder="MM/YY" -> "data-placeholder"
            unmoddedClass: "unchanged", // apply a class to the unmodded input, say, to grey it out
            parentNode: document, // limit to a particular set of child nodes
            defaultSelector: "input[placeholder]"
        },
    
        initialize: function(options) {
            this.setOptions(options);
            this.nativeSupport = 'placeholder' in document.createElement('input');
        },
    
        attachToElements: function(selector) {
            // basic function example that uses a class selector to
            var inputs = this.options.parentNode.getElements(selector || this.options.defaultSelector);
    
            if (inputs.length) {
                inputs.each(function(el) {
                    this.attachEvents(el);
                }, this);
            }
        }, // end attachToElements
    
        attachEvents: function(el, placeholder) {
            // method that attaches the events to an input element.
            var placeholder = placeholder || el.get(this.options.htmlPlaceholder);
            if (this.nativeSupport || !$(el) || !placeholder || !placeholder.length)
                return;
    
            el.set("value", placeholder).store("placeholder", placeholder);
    
            // append unmodded class to input at start
            if (this.options.unmoddedClass)
                el.addClass(this.options.unmoddedClass);
    
            // now cater for the events
            el.addEvents({
                change: function() {
                    // when value changes
                    var value = el.get("value").trim(), placeholder = el.retrieve("placeholder");
                    if (value != placeholder) {
                        // once it changes, remove this check and remove the unmoddedClass
                        el.removeClass(this.options.unmoddedClass).removeEvents("change");
                    }
                }.bind(this),
    
                focus: function() {
                    var value = el.get("value").trim(), placeholder = el.retrieve("placeholder");
                    if (value == placeholder) {
                        el.set("value", "").removeClass(this.options.unmoddedClass);
                    }
                }.bind(this),
                blur: function() {
                    var value = el.get("value").trim(), placeholder = el.retrieve("placeholder");
                    if (value == placeholder || value == "") {
                        el.set("value", placeholder).addClass(this.options.unmoddedClass);
                    }
                }.bind(this)
            });
        }
    
    });
    
    new mooPlaceholder().attachToElements();
    

    and to style, you can just use the html5 classes (vendor specific atm):

    ::-webkit-input-placeholder {
      color: red;
      font-weight: bold;
    }
    

    so it does not look like I am pimping my own class, have a look for similar solutions on the mootools forge, i know Oskar and Seanmonstar did one ( http://demo.mootools.net/forge/p/mootools_placeholder – check github for their forks) and Thierry Bela did one ( http://mootools.net/forge/p/placeholder) and there’s the Apple placeholder ( http://demo.mootools.net/forge/p/apple_placeholder)

    either way, do it the right way that will be most compatible and with longevity in mind (with feature detection, your javascript does not need to do anything which is ideal)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.