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 6973619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:07:53+00:00 2026-05-27T17:07:53+00:00

Placeholder for my textbox in below format is not working for Internet Explorer. Is

  • 0

Placeholder for my textbox in below format is not working for Internet Explorer. Is there anyway to display placeholder for TextBox in Internet Explorer?

<asp:TextBox id="email" runat="server" width="300" placeholder="Your email" />

Is there any simple way just by using any JavaScript. I am not interested to make it complicated using jQuery.

  • 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-27T17:07:54+00:00Added an answer on May 27, 2026 at 5:07 pm

    You can imitate this using pure JavaScript:

    var _debug = false;
    var _placeholderSupport = function() {
        var t = document.createElement("input");
        t.type = "text";
        return (typeof t.placeholder !== "undefined");
    }();
    
    window.onload = function() {
        var arrInputs = document.getElementsByTagName("input");
        var arrTextareas = document.getElementsByTagName("textarea");
        var combinedArray = [];
        for (var i = 0; i < arrInputs.length; i++)
            combinedArray.push(arrInputs[i]);
        for (var i = 0; i < arrTextareas.length; i++)
            combinedArray.push(arrTextareas[i]);
        for (var i = 0; i < combinedArray.length; i++) {
            var curInput = combinedArray[i];
            if (!curInput.type || curInput.type == "" || curInput.type == "text" || curInput.type == "textarea")
                HandlePlaceholder(curInput);
            else if (curInput.type == "password")
                ReplaceWithText(curInput);
        }
    
        if (!_placeholderSupport) {
            for (var i = 0; i < document.forms.length; i++) {
                var oForm = document.forms[i];
                if (oForm.attachEvent) {
                    oForm.attachEvent("onsubmit", function() {
                        PlaceholderFormSubmit(oForm);
                    });
                }
                else if (oForm.addEventListener)
                    oForm.addEventListener("submit", function() {
                        PlaceholderFormSubmit(oForm);
                    }, false);
            }
        }
    };
    
    function PlaceholderFormSubmit(oForm) {    
        for (var i = 0; i < oForm.elements.length; i++) {
            var curElement = oForm.elements[i];
            HandlePlaceholderItemSubmit(curElement);
        }
    }
    
    function HandlePlaceholderItemSubmit(element) {
        if (element.name) {
            var curPlaceholder = element.getAttribute("placeholder");
            if (curPlaceholder && curPlaceholder.length > 0 && element.value === curPlaceholder) {
                element.value = "";
                window.setTimeout(function() {
                    element.value = curPlaceholder;
                }, 100);
            }
        }
    }
    
    function ReplaceWithText(oPasswordTextbox) {
        if (_placeholderSupport)
            return;
        var oTextbox = document.createElement("input");
        oTextbox.type = "text";
        oTextbox.id = oPasswordTextbox.id;
        oTextbox.name = oPasswordTextbox.name;
        //oTextbox.style = oPasswordTextbox.style;
        oTextbox.className = oPasswordTextbox.className;
        for (var i = 0; i < oPasswordTextbox.attributes.length; i++) {
            var curName = oPasswordTextbox.attributes.item(i).nodeName;
            var curValue = oPasswordTextbox.attributes.item(i).nodeValue;
            if (curName !== "type" && curName !== "name") {
                oTextbox.setAttribute(curName, curValue);
            }
        }
        oTextbox.originalTextbox = oPasswordTextbox;
        oPasswordTextbox.parentNode.replaceChild(oTextbox, oPasswordTextbox);
        HandlePlaceholder(oTextbox);
        if (!_placeholderSupport) {
            oPasswordTextbox.onblur = function() {
                if (this.dummyTextbox && this.value.length === 0) {
                    this.parentNode.replaceChild(this.dummyTextbox, this);
                }
            };
        }
    }
    
    function HandlePlaceholder(oTextbox) {
        if (!_placeholderSupport) {
            var curPlaceholder = oTextbox.getAttribute("placeholder");
            if (curPlaceholder && curPlaceholder.length > 0) {
                Debug("Placeholder found for input box '" + oTextbox.name + "': " + curPlaceholder);
                oTextbox.value = curPlaceholder;
                oTextbox.setAttribute("old_color", oTextbox.style.color);
                oTextbox.style.color = "#c0c0c0";
                oTextbox.onfocus = function() {
                    var _this = this;
                    if (this.originalTextbox) {
                        _this = this.originalTextbox;
                        _this.dummyTextbox = this;
                        this.parentNode.replaceChild(this.originalTextbox, this);
                        _this.focus();
                    }
                    Debug("input box '" + _this.name + "' focus");
                    _this.style.color = _this.getAttribute("old_color");
                    if (_this.value === curPlaceholder)
                        _this.value = "";
                };
                oTextbox.onblur = function() {
                    var _this = this;
                    Debug("input box '" + _this.name + "' blur");
                    if (_this.value === "") {
                        _this.style.color = "#c0c0c0";
                        _this.value = curPlaceholder;
                    }
                };
            }
            else {
                Debug("input box '" + oTextbox.name + "' does not have placeholder attribute");
            }
        }
        else {
            Debug("browser has native support for placeholder");
        }
    }
    
    function Debug(msg) {
        if (typeof _debug !== "undefined" && _debug) {
            var oConsole = document.getElementById("Console");
            if (!oConsole) {
                oConsole = document.createElement("div");
                oConsole.id = "Console";
                document.body.appendChild(oConsole);
            }
            oConsole.innerHTML += msg + "<br />";
        }
    }
    

    This will do nothing if the browser is already supporting the placeholder attribute, and in case it’s not supported (e.g. the browser is IE) it will add very similar functionality – text shown by default that disappear on focus and appears again if user didn’t type anything.

    Live test case.

    Bug Fixes

    Nov 6, 2012: Previous code failed to detect when browser didn’t have native support for placeholder. Using code found in this other post it’s now fixed. Affected browsers: IE7 and IE8, maybe others as well. Also added debug support to help debug future problems.

    Jan 30, 2013:

    1. Adding support for password input as well. Since IE8 and below won’t allow dynamic change of input type, the code is replacing the password input with text input as long as there is no password typed, thus the placeholder text will be visible.

    2. Fixed bug that caused the placeholder value to be sent where empty value should be sent to the server when the form associated with the input is being submitted. To achieve this, code is attached to the form submit event and clear the value if needed.

    Jan 24, 2014: adding support for <textarea> elements.

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

Sidebar

Related Questions

I create some dynamic textbox's and a button in a placeholder and would like
There's placeholder on the page that is loaded asynchronously using jQuery load method. Page
I am adding some user controls dynamically to a PlaceHolder server control. My user
This script of mine has a function, which is not working the way, I
I have a server control, inheriting from PlaceHolder. Basically, all it is, is a
Say I have a ListView control with a TextBox control in the ItemTemplate: <asp:ListView
TL;DR: I need to insert a TextBox into a PlaceHolder wherever I see a
Chrome v4 supports the placeholder attribute on input[type=text] elements (others probably do too). However,
I have a skeleton text file with placeholder strings: blah blah blah blah $PLACEHOLDER_1$
I would like to put a placeholder into e.g. the footer.html and have it

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.