1

Im trying to create a login page using asp.net and put a placeholder on every textbox. it works well in chrome and Firefox but in IE 8 it doesn't show any placeholder. And when i put javascript codes it works ONLY in my username textbox while on my password textbox it display nothing. can anyone here help me? Please.. thank you in advance.. :) here's what i have so far..

<asp:TextBox ID="txtuser" runat="server" MaxLength="20" placeholder = "username"></asp:TextBox>
<asp:TextBox ID="txtpass" runat="server" MaxLength="25" class = "password-input" TextMode = "Password" placeholder = "Password"></asp:TextBox>

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
<script type="text/javascript">
/* <![CDATA[ */
 $(function() {
    var input = document.createElement("input");
    if (('placeholder' in input) == false) {
        $('[placeholder]').focus(function() {
            var i = $(this);
            if (i.val() == i.attr('placeholder')) {
                i.val('').removeClass('placeholder');
                if (i.hasClass('password')) {
                    i.removeClass('password');
                    this.type = 'password';
                }
            }
        }).blur(function() {
            var i = $(this);
            if (i.val() == '' || i.val() == i.attr('placeholder')) {
                if (this.type == 'password') {
                    i.addClass('password');
                    this.type = 'text';
                }
                i.addClass('placeholder').val(i.attr('placeholder'));
            }
        }).blur().parents('form').submit(function() {
            $(this).find('[placeholder]').each(function() {
                var i = $(this);
                if (i.val() == i.attr('placeholder'))
                    i.val('');
            })
        });
    }
});
/* ]]> */

eiv
  • 35
  • 1
  • 1
  • 4
  • Possible to post jsfiddle? Thank you. –  May 02 '14 at 06:28
  • @carol.. no i can't post it on jsfiddle the main problem in this is the placeholder for the password is not working on ie but it works well on the other browser. – eiv May 02 '14 at 06:44
  • Try this: http://stackoverflow.com/questions/8628522/placeholder-not-working-for-internet-explorer –  May 02 '14 at 06:46
  • it's not working.. in asp.net the textmode="password" is needed to convert the inputted value into something like this.. 1234 will be ****. another answer? thank you so much. – eiv May 02 '14 at 09:07

0 Answers0