Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-18-2012, 01:50 PM   PM User | #1
Sirag
New to the CF scene

 
Join Date: Jun 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Sirag is an unknown quantity at this point
How to fix this & make compatible with HTML5

Hello,

I've got this Persian textbox for my site it's working on most computers but some of them getting this problem when they trying to type two works which is on this keys: [] and replace of utf-8 persian char it appears [ or ] for them but not for me! Other keys are working great!

I thought maybe it needed to be updated or it has some bug need to fix.

Please anyone can help?

PHP Code:
function keyEnterToPersian(fielde) {
    if ((
field.maxLength && field.maxLength != -&& field.value.length >= field.maxLength) || field.maxLength == 0) {
        return;
    }
    var 
event document.all window.event e;
    var 
key event.keyCode event.keyCode event.which;
    if (
key 31) {
        if (
key 128) {
            var 
keys = [
                
0x00200x00210x061B0x066B0xFDFC0x066A0x060C0x06AF,
                
0x00290x00280x002A0x002B0x06480x002D0x002E0x002F,
                
0x06F00x06F10x06F20x06F30x06F40x06F50x06F60x06F7,
                
0x06F80x06F90x003A0x06A90x003E0x003D0x003C0x061F,
                
0x066C0x06240x200C0x06980x064A0x064D0x06250x0623,
                
0x06220x06510x06290x00BB0x00AB0x06210x06540x005D,
                
0x005B0x06520x064B0x06260x064F0x064E0x06700x064C,
                
0x06530x06500x06430x062C0x005C0x06860x00D70x0640,
                
0x200D0x06340x06300x06320x06CC0x062B0x06280x0644,
                
0x06270x06470x062A0x06460x06450x067E0x062F0x062E,
                
0x062D0x06360x06420x06330x06410x06390x06310x0635,
                
0x06370x063A0x06380x007D0x007C0x007B0x007E
            
];
            var 
code keys[key 32];
            if (
event.which) {
                
pnhMozStringInsert(fieldString.fromCharCode(code));
                
event.preventDefault();
            } else {
                try {
                    
event.keyCode code;
                } catch(
err) {
                }
            }
        }
    }
}
function 
pnhMozStringInsert(eltnewtext) {
    var 
posStart elt.selectionStart;
    var 
posEnd elt.selectionEnd;
    var 
scrollTop elt.scrollTop;
    var 
scrollLeft elt.scrollLeft;

    
elt.value elt.value.slice(0posStart) + newtext elt.value.slice(posEnd);
    var 
newpos posStart newtext.length;
    
elt.selectionStart newpos;
    
elt.selectionEnd newpos;
    
elt.scrollTop scrollTop;
    
elt.scrollLeft scrollLeft;
    
elt.focus();

}
function 
switchTextLang(fieldevent) {
    var 
event document.all window.event event;
    if (
event.ctrlKey && event.altKey) {
        if (
field.lang == "fa") {
            
field.dir "ltr";
            
field.onkeypress = function() {
            }
        }
        else {
            
field.dir "rtl";
            
field.onkeypress = function(event) {
                
keyEnterToPersian(thisevent);
            }
        }
    }
    
field.lang field.lang == "fa" "en" "fa";

Sirag is offline   Reply With Quote
Old 07-18-2012, 02:35 PM   PM User | #2
DrDOS
Senior Coder

 
Join Date: Sep 2010
Posts: 1,150
Thanks: 10
Thanked 148 Times in 148 Posts
DrDOS is infamous around these parts
It's written to work in a Mozilla browser, like Firefox.

pnhMozStringInsert
DrDOS is offline   Reply With Quote
Old 07-18-2012, 02:46 PM   PM User | #3
Keleth
Senior Coder

 
Join Date: Jun 2008
Location: New Jersey
Posts: 2,354
Thanks: 45
Thanked 247 Times in 244 Posts
Keleth is on a distinguished road
Well, no, there's nothing in the phnMozStringInsert function that is strictly limited to Firefox.

I'm assuming you've tried clearing your cache and trying it? Have you noticed any consistencies between computers that work such as OS and browser? The JS console doesn't show anything useful?
Keleth is offline   Reply With Quote
Reply

Bookmarks

Tags
compatible, fix, html5, textbox

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:22 PM.


Advertisement
Log in to turn off these ads.