开发者

How to parse letter numerical codes with jquery?

My problem is simple, but I can't find a way to fix it. I hope to get some help here. Since I had problems with language support on my page, I was forced to use letter codes. E.g. А Б - Russian letters А and Б. Because I don't have that much of Russian content on the page, I didn't bother to search for alternative way. But I stuck with this problem:

        function updateTips( t ) {
            tips
                .text( t )
                .addClass( "ui-state-highlight" );
            setTimeout(function() {
                tips.removeClass( "ui-state-highlight", 1500 );
            }, 500 );
        }
        function checkLength( o, n, min, max ) {
            if ( o.val().length > max || o.val().length < min ) {
                o.addClass( "ui-state-error" );
                //here is my problem situated
          开发者_运维百科      updateTips( "&#1044;&#1083;&#1080;&#1085;&#1072; " + n + " &#1076;&#1086;&#1083;&#1078;&#1085;&#1072; &#1073;&#1099;&#1090;&#1100; &#1084;&#1091;&#1078;&#1076;&#1091; " + min + " &#1080; " + max + "." );
                return false;
            } else {
                return true;
            }
        }
        function checkRegexp( o, regexp, n ) {
            if ( !( regexp.test( o.val() ) ) ) {
                o.addClass( "ui-state-error" );
                updateTips( n );
                return false;
            } else {
                return true;
            }
        }

When the code is executed, the output isn't the one I wish to see. As the output I see same "&#1044;&#1083;&#1080;&#1085;&#1072;...." and it supposed to show letters, which belong to those codes. Any advise or alternative way for fixing this issue would be appreciated. Thank you in advance.


In function updateTips( t ), change .text to .html.

This should fix it.

Edit:

The reason for this is because the point of .text() is explicitly to not interpret whatever is in the string. It's meant for things like XML, where you need the string exactly as it was passed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜