×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Mar 2013
    Location
    Goa, India
    Posts
    32

    Numeric password box for windows phone

    Hi all,

    I need numeric password box for my application. But windows phone do not have input scope options for password box due to security reasons. While searching for this almost everywhere its recommnded to implement a custom control. I wonder if there is an easy way for achieving this.? I have no idea about implementing custom control for windows phone.

    Regards

  2. #2
    Registered User
    Join Date
    Feb 2007
    Location
    Tampere
    Posts
    370

    Re: Numeric password box for windows phone

    Regards

    - MVP
    "Dare To Dream" - A.P.J.Kalam

  3. #3
    Nokia Developer Champion
    Join Date
    Sep 2012
    Location
    Morocco
    Posts
    291

    Re: Numeric password box for windows phone

    Quote Originally Posted by Kunal Prime View Post
    Hi all,

    I need numeric password box for my application. But windows phone do not have input scope options for password box due to security reasons. While searching for this almost everywhere its recommnded to implement a custom control. I wonder if there is an easy way for achieving this.? I have no idea about implementing custom control for windows phone.

    Regards
    You can use a TextBox, assign the input scope, and implement the changed event ( storing the new entered number and replacing it with "*" like this YourTextBox.Text[lenght-1] = '*' )

  4. #4
    Nokia Developer Expert
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,140

    Re: Numeric password box for windows phone

    Quote Originally Posted by Loukt View Post
    You can use a TextBox, assign the input scope, and implement the changed event ( storing the new entered number and replacing it with "*" like this YourTextBox.Text[lenght-1] = '*' )
    you could use one of the latest examples as a base: http://www.developer.nokia.com/Commu...rical_inputbox . Basically illustrating different usage scenario, but should be rather easy to modify.

  5. #5
    Registered User
    Join Date
    Mar 2013
    Location
    Goa, India
    Posts
    32

    Re: Numeric password box for windows phone

    Hi all,

    @Loukt : Thanks for your suggestion. It gave me a point to start. Took the same logic as you suggested, just that implemented KeyUp method rather than TextChanged. Though it seemed simple at first but actually it was not. You have to keep track of actual text separately as you replace it with *. Dont know if i complicated it. I will post the logic soon and let me know if it can be simplified.

    @mrudulpen , symbianyucca : Thanks for your help. Will help me in learning "How to create custom controls".

    Regards

  6. #6
    Registered User
    Join Date
    Mar 2013
    Location
    Goa, India
    Posts
    32

    Re: Numeric password box for windows phone

    Hi all,
    <TextBox Name="PasswordTextBox" InputScope="Number" KeyUp="PasswordTextBox_KeyUp"/>
    string _enteredPasscode = "";

    private void PasswordTextBox_KeyUp(object sender, KeyEventArgs e)
    {
    //modify new passcode according to entered key
    _enteredPasscode = GetNewPasscode(_enteredPasscode, e.PlatformKeyCode);

    //replace text by *
    PasswordTextBox.Text = Regex.Replace(_enteredPasscode, @".", "*");

    //take cursor to end of string
    PasswordTextBox.SelectionStart = TextBox.Text.Length;
    }


    private string GetNewPasscode(string oldPasscode, int keyId)
    {
    string newPasscode = string.Empty;
    switch (keyId)
    {
    case 8:
    //back key pressed
    if (oldPasscode.Length > 0)
    newPasscode = oldPasscode.Substring(0, oldPasscode.Length - 1);
    break;
    case 190:
    // . pressed
    newPasscode = oldPasscode;
    break;
    default:
    //Number pressed
    newPasscode = oldPasscode + (keyId - 48);
    break;
    }
    return newPasscode;
    }
    Ended up with above code. Let me know if it can be simplified

    Regards
    Last edited by Kunal Prime; 2013-03-07 at 11:40.

Similar Threads

  1. Windows phone 8 app installation on phone without putting it on windows store
    By KnowledgeSeeker in forum Windows Phone General
    Replies: 2
    Last Post: 2013-03-05, 12:12
  2. Password field with default numeric type but support alphanumeric
    By mazhar_cse in forum Symbian User Interface
    Replies: 4
    Last Post: 2011-09-12, 14:39
  3. Password alphanumeric and numeric
    By FrankTheFox in forum Symbian User Interface
    Replies: 4
    Last Post: 2009-01-19, 19:02
  4. CommandListener on TextField.NUMERIC || TextField.PASSWORD
    By lekkie in forum Mobile Java General
    Replies: 3
    Last Post: 2007-07-09, 13:42
  5. TextBox to enter numeric password Ser 40
    By andretr in forum Mobile Java Tools & SDKs
    Replies: 0
    Last Post: 2004-06-14, 20:58

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •