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.
Posts Related to Show special characters in javascript alert
Maximum Charactors/Words limit(counter) for textarea using Javascript/jQuery
Hello Friends, Are you looking for limiting charactors/words entered in textarea? Today i need to implement the limit for description field where customer can only ...
Javascript floating point precision(Sets the number of decimal points)
Hello Friends, If you have a problem with floating point precision when you update any number in html using javascript/jquery than here i show ...
How to differentiate Addition Operator with Concatenation Operator in Javascript
All we know about Concatenation operator (+) in JavaScript which combine two string with "+" operator in java Script(If you want to do concatenation in ...
Javascript validation : Date Comparision not working
In most of the web application , Javascript is one of the must needed scripting language. There are some problem happens when you will write ...
Clustered indexes Vs Non-clustered indexes
A clustered index is a special type of index that reorders the records in the table are physically stored. In non-technical way, you are telling ...
You can leave a response or trackback from your own site.






I am