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.
Related posts:
- Implementing Google Maps using API on your website
- Maximum Charactors/Words limit(counter) for textarea using Javascript/jQuery
- Javascript validation : Date Comparision not working
- jQuery validation : End date should be Greater than Start date
- How to differentiate Addition Operator with Concatenation Operator in Javascript
You can leave a response or trackback from your own site.



I am
Recent Comments