[cfaussie] Re: CF reports different length than JS
Thanks Pete! Much appreciated.. On 4/12/07, Pete [EMAIL PROTECTED] wrote: IE 7 represents a newline as chr(13)chr(10) - 2 bytes and FF 2 as chr(10) - 1 byte textarea 0123456789 0123456789 0123456789 0123456789 /textarea Using the above data IE gives: 40 chars + 4 Newlines * (2 chars) = 48 chars FF gives: 40 chars + 4 Newlines * (1 char) = 44 chars so all we need to do is remove the chr(13) from the string using the following js var text = document.getElementById('test').value; newText = text.replace(/\n/g,''); if you don't want to count the newlines at all then newtext = text.replace(/\r|\n/g,''); which will report 40 chars in IE and FF Cheers, Pete On Apr 12, 6:49 am, Taco Fleur [EMAIL PROTECTED] wrote: Thanks Mark, that's really comforting that I am not alone.. but still have to search for a solution ;-) On 4/11/07, Mark Mandel [EMAIL PROTECTED] wrote: Just so you know, I hit this bug also ages ago where the length given by FF and the length given by IE were totally different. I forget what the workaround was... but know that you aren't alone ;o) Mark -- E: [EMAIL PROTECTED] W:www.compoundtheory.com -- Taco Fleur -http://www.pacificfox.com.au Web Design, Web development, Graphic Design and Complete Internet Solutions an industry leader with commercial IT experience since 1994 ... -- Taco Fleur - http://www.pacificfox.com.au Web Design, Web development, Graphic Design and Complete Internet Solutions an industry leader with commercial IT experience since 1994 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups cfaussie group. To post to this group, send email to [EMAIL PROTECTED] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~--~~~~--~~--~--~---
[cfaussie] Re: CF reports different length than JS
IE 7 represents a newline as chr(13)chr(10) - 2 bytes and FF 2 as chr(10) - 1 byte textarea 0123456789 0123456789 0123456789 0123456789 /textarea Using the above data IE gives: 40 chars + 4 Newlines * (2 chars) = 48 chars FF gives: 40 chars + 4 Newlines * (1 char) = 44 chars so all we need to do is remove the chr(13) from the string using the following js var text = document.getElementById('test').value; newText = text.replace(/\n/g,''); if you don't want to count the newlines at all then newtext = text.replace(/\r|\n/g,''); which will report 40 chars in IE and FF Cheers, Pete On Apr 12, 6:49 am, Taco Fleur [EMAIL PROTECTED] wrote: Thanks Mark, that's really comforting that I am not alone.. but still have to search for a solution ;-) On 4/11/07, Mark Mandel [EMAIL PROTECTED] wrote: Just so you know, I hit this bug also ages ago where the length given by FF and the length given by IE were totally different. I forget what the workaround was... but know that you aren't alone ;o) Mark -- E: [EMAIL PROTECTED] W:www.compoundtheory.com -- Taco Fleur -http://www.pacificfox.com.au Web Design, Web development, Graphic Design and Complete Internet Solutions an industry leader with commercial IT experience since 1994 ... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups cfaussie group. To post to this group, send email to [EMAIL PROTECTED] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~--~~~~--~~--~--~---
[cfaussie] Re: CF reports different length than JS
Just so you know, I hit this bug also ages ago where the length given by FF and the length given by IE were totally different. I forget what the workaround was... but know that you aren't alone ;o) Mark -- E: [EMAIL PROTECTED] W: www.compoundtheory.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups cfaussie group. To post to this group, send email to cfaussie@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~--~~~~--~~--~--~---
[cfaussie] Re: CF reports different length than JS
*cough cough Who was the one who fixed it for you? -Original Message- From: cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Mark Mandel Sent: Wednesday, 11 April 2007 6:15 PM To: cfaussie@googlegroups.com Subject: [cfaussie] Re: CF reports different length than JS Just so you know, I hit this bug also ages ago where the length given by FF and the length given by IE were totally different. I forget what the workaround was... but know that you aren't alone ;o) Mark -- E: [EMAIL PROTECTED] W: www.compoundtheory.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups cfaussie group. To post to this group, send email to cfaussie@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~--~~~~--~~--~--~---
[cfaussie] Re: CF reports different length than JS
Steve, I thought that IE was the same and that a return was \n, I know I use that in JS all the time and it never complains, and works as expected. But Taco, yeah an example string would be good. Andrew Scott Senior Coldfusion Developer Aegeon Pty. Ltd. www.aegeon.com.au Phone: +613 8676 4223 Mobile: 0404 998 273 From: cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Steve Onnis Sent: Wednesday, 11 April 2007 2:38 PM To: cfaussie@googlegroups.com Subject: [cfaussie] Re: CF reports different length than JS It actually depends on the browser. For example, in IE a return is \n\n where in FireFox a return is \n so you get a different in length. In Coldfusion a line break will be different also. I think thats where your getting your lengths screwing up. Steve --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups cfaussie group. To post to this group, send email to cfaussie@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~--~~~~--~~--~--~---
[cfaussie] Re: CF reports different length than JS
It is actually Firefox that creates the problem. I just tested it and IE is OK with the following random string. IE reports 400 chars and Firefox reports more, so it must be what Steve says and it uses \n\n for new lines. I guess we'll have to do some regex replacing, hmm wonder how this is going to affect things -- hfghdf gh dfhgdfgjk dfjkg kjdfnnjndfk nbjklcvnjkbn cvjknbjkncv jbncjvnbjkn cvjkbnjkcv jkbncjkvb jkcvjkbjkc vbjkncjkvn cv b cv b c v b cvb cvbcv bcvb cv b cv b cv b cv bc vb cv b cvbcvhfghdf gh dfhgdfgjk dfjkg kjdfnnjndfk nbjklcvnjkbn cvjknbjkncv jbncjvnbjkn cvjkbnjkcv jkbncjkvb jkcvjkbjkc vbjkncjkvn cv b cv b c v b cvb cvbcv bcvb cv b cv b cv b cv bc vb cv b cvbcvhfghdf gh dfhgdfgjk dfjk -- On 4/11/07, Steve Onnis [EMAIL PROTECTED] wrote: It actually depends on the browser. For example, in IE a return is \n\n where in FireFox a return is \n so you get a different in length. In Coldfusion a line break will be different also. I think thats where your getting your lengths screwing up. Steve -- *From:* cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] *On Behalf Of *Dale Fraser *Sent:* Wednesday, 11 April 2007 2:34 PM *To:* cfaussie@googlegroups.com *Subject:* [cfaussie] Re: CF reports different length than JS Should be the same, Are you sure there are no funny characters that CF is stripping or JS. Can you post an example string where they are different. Regards Dale Fraser http://dale.fraser.id.au/blog *From:* cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] *On Behalf Of *Taco Fleur *Sent:* Wednesday, 11 April 2007 2:15 PM *To:* cfaussie@googlegroups.com *Subject:* [cfaussie] CF reports different length than JS Hi all, I'm doing some server-side checking as well as client-side, and am finding that CF7 reports a different length of characters than JavaScript does. Not sure about the internals of both functions, but am hoping I can sort of get the two in sync. Anyone any ideas? len() VS obj.value.length I reckon it might have something to do with line breaks. Thanks in advance. -- Taco Fleur - http://www.pacificfox.com.au Web Design, Web development, Graphic Design and Complete Internet Solutions an industry leader with commercial IT experience since 1994 -- Taco Fleur - http://www.pacificfox.com.au Web Design, Web development, Graphic Design and Complete Internet Solutions an industry leader with commercial IT experience since 1994 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups cfaussie group. To post to this group, send email to cfaussie@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~--~~~~--~~--~--~---
[cfaussie] Re: CF reports different length than JS
textarea id=str /textarea br / script document.write(Length : + document.getElementById(str).value.length + br /); for (i=0; i document.getElementById(str).value.length; ++i) { document.write(Char Code at position + i + : + document.getElementById(str).value.charCodeAt(i) + br /); } /script IE says the length is 2 but FireFox says its 1. You can also see the char code that is being used for the carrage returns. _ From: cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Andrew Scott Sent: Wednesday, 11 April 2007 2:51 AM To: cfaussie@googlegroups.com Subject: [cfaussie] Re: CF reports different length than JS Steve, I thought that IE was the same and that a return was \n, I know I use that in JS all the time and it never complains, and works as expected. But Taco, yeah an example string would be good. Andrew Scott Senior Coldfusion Developer Aegeon Pty. Ltd. www.aegeon.com.au Phone: +613 8676 4223 Mobile: 0404 998 273 From: cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Steve Onnis Sent: Wednesday, 11 April 2007 2:38 PM To: cfaussie@googlegroups.com Subject: [cfaussie] Re: CF reports different length than JS It actually depends on the browser. For example, in IE a return is \n\n where in FireFox a return is \n so you get a different in length. In Coldfusion a line break will be different also. I think thats where your getting your lengths screwing up. Steve --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups cfaussie group. To post to this group, send email to cfaussie@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~--~~~~--~~--~--~---
[cfaussie] Re: CF reports different length than JS
Hi, No I don't have it installed, but will give it a go... On 4/11/07, Andrew Scott [EMAIL PROTECTED] wrote: Taco, Do you have firebug installed in FF? Might pay to use that to check the string out. Andrew Scott Senior Coldfusion Developer Aegeon Pty. Ltd. www.aegeon.com.au Phone: +613 8676 4223 Mobile: 0404 998 273 *From:* cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] *On Behalf Of *Taco Fleur *Sent:* Wednesday, 11 April 2007 3:01 PM *To:* cfaussie@googlegroups.com *Subject:* [cfaussie] Re: CF reports different length than JS It is actually Firefox that creates the problem. I just tested it and IE is OK with the following random string. IE reports 400 chars and Firefox reports more, so it must be what Steve says and it uses \n\n for new lines. I guess we'll have to do some regex replacing, hmm wonder how this is going to affect things -- hfghdf gh dfhgdfgjk dfjkg kjdfnnjndfk nbjklcvnjkbn cvjknbjkncv jbncjvnbjkn cvjkbnjkcv jkbncjkvb jkcvjkbjkc vbjkncjkvn cv b cv b c v b cvb cvbcv bcvb cv b cv b cv b cv bc vb cv b cvbcvhfghdf gh dfhgdfgjk dfjkg kjdfnnjndfk nbjklcvnjkbn cvjknbjkncv jbncjvnbjkn cvjkbnjkcv jkbncjkvb jkcvjkbjkc vbjkncjkvn cv b cv b c v b cvb cvbcv bcvb cv b cv b cv b cv bc vb cv b cvbcvhfghdf gh dfhgdfgjk dfjk -- On 4/11/07, *Steve Onnis* [EMAIL PROTECTED] wrote: It actually depends on the browser. For example, in IE a return is \n\n where in FireFox a return is \n so you get a different in length. In Coldfusion a line break will be different also. I think thats where your getting your lengths screwing up. Steve -- *From:* cfaussie@googlegroups.com [mailto: [EMAIL PROTECTED] *On Behalf Of *Dale Fraser *Sent:* Wednesday, 11 April 2007 2:34 PM *To:* cfaussie@googlegroups.com *Subject:* [cfaussie] Re: CF reports different length than JS Should be the same, Are you sure there are no funny characters that CF is stripping or JS. Can you post an example string where they are different. Regards Dale Fraser http://dale.fraser.id.au/blog *From:* cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] *On Behalf Of *Taco Fleur *Sent: *Wednesday, 11 April 2007 2:15 PM *To:* cfaussie@googlegroups.com *Subject:* [cfaussie] CF reports different length than JS Hi all, I'm doing some server-side checking as well as client-side, and am finding that CF7 reports a different length of characters than JavaScript does. Not sure about the internals of both functions, but am hoping I can sort of get the two in sync. Anyone any ideas? len() VS obj.value.length I reckon it might have something to do with line breaks. Thanks in advance. -- Taco Fleur - http://www.pacificfox.com.au Web Design, Web development, Graphic Design and Complete Internet Solutions an industry leader with commercial IT experience since 1994 Web Design, Web development, Graphic Design and Complete Internet Solutions an industry leader with commercial IT experience since 1994 -- Taco Fleur - http://www.pacificfox.com.au Web Design, Web development, Graphic Design and Complete Internet Solutions an industry leader with commercial IT experience since 1994 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups cfaussie group. To post to this group, send email to cfaussie@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~--~~~~--~~--~--~---
[cfaussie] Re: CF reports different length than JS
Andrew, installed firebug, not sure how to check the string out, any tips? On 4/11/07, Andrew Scott [EMAIL PROTECTED] wrote: Taco, Do you have firebug installed in FF? Might pay to use that to check the string out. Andrew Scott Senior Coldfusion Developer Aegeon Pty. Ltd. www.aegeon.com.au Phone: +613 8676 4223 Mobile: 0404 998 273 *From:* cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] *On Behalf Of *Taco Fleur *Sent:* Wednesday, 11 April 2007 3:01 PM *To:* cfaussie@googlegroups.com *Subject:* [cfaussie] Re: CF reports different length than JS It is actually Firefox that creates the problem. I just tested it and IE is OK with the following random string. IE reports 400 chars and Firefox reports more, so it must be what Steve says and it uses \n\n for new lines. I guess we'll have to do some regex replacing, hmm wonder how this is going to affect things -- hfghdf gh dfhgdfgjk dfjkg kjdfnnjndfk nbjklcvnjkbn cvjknbjkncv jbncjvnbjkn cvjkbnjkcv jkbncjkvb jkcvjkbjkc vbjkncjkvn cv b cv b c v b cvb cvbcv bcvb cv b cv b cv b cv bc vb cv b cvbcvhfghdf gh dfhgdfgjk dfjkg kjdfnnjndfk nbjklcvnjkbn cvjknbjkncv jbncjvnbjkn cvjkbnjkcv jkbncjkvb jkcvjkbjkc vbjkncjkvn cv b cv b c v b cvb cvbcv bcvb cv b cv b cv b cv bc vb cv b cvbcvhfghdf gh dfhgdfgjk dfjk -- On 4/11/07, *Steve Onnis* [EMAIL PROTECTED] wrote: It actually depends on the browser. For example, in IE a return is \n\n where in FireFox a return is \n so you get a different in length. In Coldfusion a line break will be different also. I think thats where your getting your lengths screwing up. Steve -- *From:* cfaussie@googlegroups.com [mailto: [EMAIL PROTECTED] *On Behalf Of *Dale Fraser *Sent:* Wednesday, 11 April 2007 2:34 PM *To:* cfaussie@googlegroups.com *Subject:* [cfaussie] Re: CF reports different length than JS Should be the same, Are you sure there are no funny characters that CF is stripping or JS. Can you post an example string where they are different. Regards Dale Fraser http://dale.fraser.id.au/blog *From:* cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] *On Behalf Of *Taco Fleur *Sent: *Wednesday, 11 April 2007 2:15 PM *To:* cfaussie@googlegroups.com *Subject:* [cfaussie] CF reports different length than JS Hi all, I'm doing some server-side checking as well as client-side, and am finding that CF7 reports a different length of characters than JavaScript does. Not sure about the internals of both functions, but am hoping I can sort of get the two in sync. Anyone any ideas? len() VS obj.value.length I reckon it might have something to do with line breaks. Thanks in advance. -- Taco Fleur - http://www.pacificfox.com.au Web Design, Web development, Graphic Design and Complete Internet Solutions an industry leader with commercial IT experience since 1994 Web Design, Web development, Graphic Design and Complete Internet Solutions an industry leader with commercial IT experience since 1994 -- Taco Fleur - http://www.pacificfox.com.au Web Design, Web development, Graphic Design and Complete Internet Solutions an industry leader with commercial IT experience since 1994 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups cfaussie group. To post to this group, send email to cfaussie@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~--~~~~--~~--~--~---
[cfaussie] Re: CF reports different length than JS
Ok you have a number of options, in this case you could create a dive and use DHMTL to place the string into the div then use the inspect to view the data inside the div. I use dojo and it has a brilliant debug option which not only shows the string but it as an object, which shows \n\n\n String text \n\n more text But I can't answer 100% sure if doing this and going to the dom would be sufficient enough. You could try console.log(string); never used it but you it might have options to view more details about the string or object in question. Andrew Scott Senior Coldfusion Developer Aegeon Pty. Ltd. www.aegeon.com.au Phone: +613 8676 4223 Mobile: 0404 998 273 From: cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Taco Fleur Sent: Wednesday, 11 April 2007 3:25 PM To: cfaussie@googlegroups.com Subject: [cfaussie] Re: CF reports different length than JS Andrew, installed firebug, not sure how to check the string out, any tips? On 4/11/07, Andrew Scott [EMAIL PROTECTED] wrote: Taco, Do you have firebug installed in FF? Might pay to use that to check the string out. Andrew Scott Senior Coldfusion Developer Aegeon Pty. Ltd. www.aegeon.com.au http://www.aegeon.com.au/ Phone: +613 8676 4223 Mobile: 0404 998 273 From: cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Taco Fleur Sent: Wednesday, 11 April 2007 3:01 PM To: cfaussie@googlegroups.com Subject: [cfaussie] Re: CF reports different length than JS It is actually Firefox that creates the problem. I just tested it and IE is OK with the following random string. IE reports 400 chars and Firefox reports more, so it must be what Steve says and it uses \n\n for new lines. I guess we'll have to do some regex replacing, hmm wonder how this is going to affect things -- hfghdf gh dfhgdfgjk dfjkg kjdfnnjndfk nbjklcvnjkbn cvjknbjkncv jbncjvnbjkn cvjkbnjkcv jkbncjkvb jkcvjkbjkc vbjkncjkvn cv b cv b c v b cvb cvbcv bcvb cv b cv b cv b cv bc vb cv b cvbcvhfghdf gh dfhgdfgjk dfjkg kjdfnnjndfk nbjklcvnjkbn cvjknbjkncv jbncjvnbjkn cvjkbnjkcv jkbncjkvb jkcvjkbjkc vbjkncjkvn cv b cv b c v b cvb cvbcv bcvb cv b cv b cv b cv bc vb cv b cvbcvhfghdf gh dfhgdfgjk dfjk -- On 4/11/07, Steve Onnis [EMAIL PROTECTED] wrote: It actually depends on the browser. For example, in IE a return is \n\n where in FireFox a return is \n so you get a different in length. In Coldfusion a line break will be different also. I think thats where your getting your lengths screwing up. Steve _ From: cfaussie@googlegroups.com [mailto: cfaussie@googlegroups.com mailto:cfaussie@googlegroups.com ] On Behalf Of Dale Fraser Sent: Wednesday, 11 April 2007 2:34 PM To: cfaussie@googlegroups.com Subject: [cfaussie] Re: CF reports different length than JS Should be the same, Are you sure there are no funny characters that CF is stripping or JS. Can you post an example string where they are different. Regards Dale Fraser http://dale.fraser.id.au/blog From: cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Taco Fleur Sent: Wednesday, 11 April 2007 2:15 PM To: cfaussie@googlegroups.com Subject: [cfaussie] CF reports different length than JS Hi all, I'm doing some server-side checking as well as client-side, and am finding that CF7 reports a different length of characters than JavaScript does. Not sure about the internals of both functions, but am hoping I can sort of get the two in sync. Anyone any ideas? len() VS obj.value.length I reckon it might have something to do with line breaks. Thanks in advance. -- Taco Fleur - http://www.pacificfox.com.au http://www.pacificfox.com.au/ Web Design, Web development, Graphic Design and Complete Internet Solutions an industry leader with commercial IT experience since 1994 . Web Design, Web development, Graphic Design and Complete Internet Solutions an industry leader with commercial IT experience since 1994 . Web Design, Web development, Graphic Design and Complete Internet Solutions an industry leader with commercial IT experience since 1994 . --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups cfaussie group. To post to this group, send email to cfaussie@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~--~~~~--~~--~--~---