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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:15:13+00:00 2026-06-09T11:15:13+00:00

How to do password masking as in Android mobile like when we type in

  • 0

How to do password masking as in Android mobile like when we type in a key it shows a key for few seconds and change it to “*”.
I tried the plugin mentioned in Password masking as in mobiles using js it is not optimal. And the jsfiddle http://jsfiddle.net/medopal/X37Wz/ not able to handle backspace and delete. Could you please suggest any other methods to do this? Only using jquery and not to use plugins.

  • 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-06-09T11:15:15+00:00Added an answer on June 9, 2026 at 11:15 am

    here i have done complete solution bin for above query. please check demo link as given below:

    Demo: http://codebins.com/bin/4ldqp8u

    HTML:

    <div id="panel">
      <input type="text" id="txtpwd" name="txtpwd" size="15"/>
      <input type="text" id="txthidden" name="txthidden" size="15"/>
      <div>
        KeyCode Pressed: 
        <span id="keycode">
        </span>
      </div>
    </div>
    

    JQuery:

    $(function() {
        //Extends JQuery Methods to get current cursor postion in input text.
        //GET CURSOR POSITION
        jQuery.fn.getCursorPosition = function() {
            if (this.lengh == 0) return -1;
            return $(this).getSelectionStart();
        }
    
        jQuery.fn.getSelectionStart = function() {
            if (this.lengh == 0) return -1;
            input = this[0];
    
            var pos = input.value.length;
    
            if (input.createTextRange) {
                var r = document.selection.createRange().duplicate();
                r.moveEnd('character', input.value.length);
                if (r.text == '') pos = input.value.length;
                pos = input.value.lastIndexOf(r.text);
            } else if (typeof(input.selectionStart) != "undefined") pos = input.selectionStart;
    
            return pos;
        }
    
        //Bind Key Press event with password field    
        $("#txtpwd").keypress(function(e) {
            setTimeout(function() {
                maskPassword(e)
            }, 500);
        });
    
    });
    
    function generateStars(n) {
        var stars = '';
        for (var i = 0; i < n; i++) {
            stars += '*';
        }
        return stars;
    }
    
    function maskPassword(e) {
    
        var text = $('#txthidden').val().trim();
        var stars = $('#txthidden').val().trim().length;
        var unicode = e.keyCode ? e.keyCode : e.charCode;
        $("#keycode").html(unicode);
    
        //Get Current Cursor Position on Password Textbox
        var curPos = $("#txtpwd").getCursorPosition();
        var PwdLength = $("#txtpwd").val().trim().length;
    
        if (unicode != 9 && unicode != 13 && unicode != 37 && unicode != 40 && unicode != 37 && unicode != 39) {
            //If NOT <Back Space> OR <DEL> Then...
            if (unicode != 8 && unicode != 46) {
                text = text + String.fromCharCode(unicode);
                stars += 1;
            }
            //If Press <Back Space> Or <DEL> Then...
            else if ((unicode == 8 || unicode == 46) && stars != PwdLength) {
                stars -= 1;
                text = text.replace(text.charAt(curPos), "");
            }
            //Set New String on both input fields
            $('#txthidden').val(text);
            $('#txtpwd').val(generateStars(stars));
        }
    
    }
    

    Demo: http://codebins.com/bin/4ldqp8u

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

Sidebar

Related Questions

My password contains special characters like '&' and VS giving error on this like
I've been making a jQuery plugin for password boxes. It adds a generate password
I am a new to Yii. I am making a change password page for
I am thinking of making a password sequence for my app, like that in
Does anybody know how (and if) you can change the password used to sign
I'm wondering if I have a web service like this: Login(username, password) or a
http://developer.android.com/reference/android/widget/TextView.html#attr_android:password I can't find where in the android code it applied the android:password xml
When using Microsft Exchange, Android activates its password screen wich the user needs to
How to make CLI password masking in Lua? E.g. when I write password it
I'm making a system to change my password and I don't know why I

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.