Looking to Build/Redesign a Website or Blog ?

To speak to Rakshit, call +91 968 704 2303

Show special characters in javascript alert

Hello Friends,

Are you facing problem in showing special characters in javascript alert ? Are you facing problem in showing language special characters in javascript alert ? I was working in danish, french and other international language and validating form using javascript alert. When value is not entered by visitor in form and we show alert message than for some special character, it shows question mark message in javascript alert.

So for this type of problem you can write the Decimal numbers for the special characters and use the below function which convert the Decimal numbers into special characters and alert the message.

For Converting the special character into Decimal number, you can use the below link to find out appropriate decimal number of your language special character.


function deCode(str)
var convertstr;
convertstr = str.replace(/\&\#(\d+)\;/g, function(p1,p2){ return String.fromCharCode(p2) } );
return convertstr;

What you need to do is…
1) Copy above function and paste it in script tag.
2) Find the decimal character of your special character of language.(for e.g æ id for æ.)
3) Replace the decimal character in string which you write in alert().
4) Write alert string in deCode().
5) Thats it.

Let me know your thoughts for the same. If you face any problem in this than let me know via comment or contact us form.

To know more about programming,JavaScript issues,jQuery,Expression Engine,MYSQL database and Open-source, enter your email address below. We will send you free tutorials.

Enter your email address:
Feel free to ask any question. Just leave your comment below and we will answer your comment with in 24 hours.


  • Hi,i read yokur blog from time to time and i own
    a similar one and i was just wondering if you get a lot of
    spam feedback? If so how do you reduce it, aany plugin or anything you can recommend?

    I get so much lately it’s driving me inssne so any help is very mmuch appreciated.

  • I don’t even know how I ended up here, but I thought this post was
    great. I don’t know who you are but certainly you’re going to a famous blogger if you are not
    already 😉 Cheers!

Leave a Reply

Your email address will not be published.