Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jul 2002
    Posts
    47
    Thanks
    1
    Thanked 0 Times in 0 Posts

    problem characters

    I have a .net page and in .net, there's no way to easily set the value of a textbox that has it's property set to password. So, I figured a workaround would be to write some javascript to the page that populates that field after the page loads. This works fine except for one person's password that contains a "\" character. So, for example, their password is E032\j1 and after I populate it, I alert the value and get E032j1. Is there a way to make sure that any character in the password is populated instead of removed? Thanks.

  • #2
    Senior Coder
    Join Date
    Feb 2003
    Posts
    1,665
    Thanks
    0
    Thanked 27 Times in 25 Posts
    The backslash is read by the browser as an escape character, meaning that the character that follows the backslash should be taken literally (rather than interpreted as a special character).
    To get the backslash to appear as part of a string - in this case, your password - escape it (i.e. escape the backslash)

    When you autofill the password value, escape the backslash, by placing a backslash before it.

    e.g.
    Code:
    document.forms[0].elements[0].value = 'E032\\j1';
    When you alert that form field value, it should give the correct password, including the single backslash.

  • #3
    New Coder
    Join Date
    Jul 2002
    Posts
    47
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thank you, that worked fine.


  •  

    Posting Permissions

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