Thursday , 23 October 2014
Home » PHP Programming » Common Issues/Bugs » Show special characters in javascript alert
Show special characters in javascript alert

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.
http://htmlhelp.com/reference/html40/entities/latin1.html

 

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.

About Rakshit Patel

I am PHP Freelancer, Rakshit Patel AKA WordPress Freelancer working as PHP Programmer India. I am here to share all my developing knowledge, quick coding techniques, quick solutions to save your time and help you guys for any issue or bug fixing. If you have any PHP, WordPress, Magento related work, please contact me. I am interested for the work.

3 comments

  1. 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.

  2. 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. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>