Show pound sign in input field by Javascript


If you have ever tried to put pound sign (or any special character) in any input fields by Javascript, you know that it is not that straight forward.

If we write code like this,
document.getElementById('input_field_id').value = '£1000';
It’ll display some question mark(unrecognized character) instead of the pound sign.
So we need to put character’s unicode to display it properly. In this case, the code should look like this:
document.getElementById('input_field_id').value = '\u00A31000';
where \u00A3 is the character code of £

This was bugging me a lot, so I thought it does not bug any one else :)

,

  1. #1 by Richard on August 17, 2010 - 8:39 pm

    Great Post Javascript HTML entity pound sign

  2. #2 by DrPaul on March 9, 2011 - 8:40 pm

    Thank you, thank you, thank you, thank you, thank you!!!

    You just saved my sanity :-)

  3. #3 by MJ7 on July 6, 2011 - 2:02 pm

    Thank you – just what I was looking for.

  4. #4 by daemon on August 2, 2011 - 11:45 am

    hm, nice post.
    btw, I have some nice looking british pound symbol images on my site:
    http://www.britishpoundsymbol.com

    please feel free to download and use them in your documens, blogs, sites etc.

    regards

  5. #5 by Steven on October 27, 2011 - 3:37 am

    Thanks very much! I have been searching for this answer for about an hour :-)

  6. #6 by Derek M on February 29, 2012 - 4:08 pm

    The web is better place for people like you – many thanks!

  7. #7 by Harit on July 12, 2012 - 10:17 pm

    Thanks a lot man, that saved a lot of time for me :) cheers

  8. #8 by Simon on August 15, 2013 - 6:44 pm

    Just spent over an hour trying to show pound signs
    Thanks for your nice, easy to follow solution

(will not be published)