SitePoint Enthusiast
Chinese characters in Alert?
Hi,
I've got a chinese version of a site that I've translated everything except the Alert boxes.
Here's the English version:
<script language="JavaScript">
function validateForm(part_search) {
var partsearch = part_search.partsearch.value;
if (partsearch == "") {
alert("Please insert a Part Number.");
return false; }
return true;}
</script>
Please insert a Part Number = 请输入型号
So.. I've tried both decimal values (#35831;#36755;#20837;#22411;#21495; ....Removed &'s or else this interface will display Chinese characters)
<script language="JavaScript">
function validateForm(part_search) {
var partsearch = part_search.partsearch.value;
if (partsearch == "#35831;#36755;#20837;#22411;#21495;") {
alert("");
return false; }
return true;}
</script>
This just displays raw #35831;#36755;#20837;#22411;#21495;
and Unicode:
<script language="JavaScript">
function validateForm(part_search) {
var partsearch = part_search.partsearch.value;
if (partsearch == "") {
alert("\u8BF7\u8F93\u5165\u578B\u53F7");
return false; }
return true;}
</script>
This displays boxes...
What am I doing wrong??
Thanks
Web-coding NINJA!
Hmm, it doesn't appear that you can. I know that for Chinese you need to be using the Big5 encoding and have the language pack installed (or a native install). I did both of those and tried your code with both unicode and ascii escapes, but always get the boxes.
I'll have to reasearch this -- maybe per the ECMA spec, javascript only supports certain character sets.
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Bookmarks