Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #17432 > unrolled thread
| Started by | justaguy <lichunshen84@gmail.com> |
|---|---|
| First post | 2012-12-03 13:04 -0800 |
| Last post | 2012-12-03 23:15 +0200 |
| Articles | 12 — 6 participants |
Back to article view | Back to comp.lang.javascript
IE9 is not a friend... justaguy <lichunshen84@gmail.com> - 2012-12-03 13:04 -0800
Re: IE9 is not a friend... Andrew Poulos <ap_prog@hotmail.com> - 2012-12-04 08:10 +1100
Re: IE9 is not a friend... Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2012-12-03 22:41 +0100
Re: IE9 is not a friend... justaguy <lichunshen84@gmail.com> - 2012-12-03 14:06 -0800
Re: IE9 is not a friend... justaguy <lichunshen84@gmail.com> - 2012-12-03 14:27 -0800
Re: IE9 is not a friend... Christoph Becker <cmbecker69@gmx.de> - 2012-12-04 15:05 +0100
Re: IE9 is not a friend... Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-12-03 23:20 +0100
Re: IE9 is not a friend... Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2012-12-03 23:41 +0100
Re: IE9 is not a friend... Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-12-04 15:23 +0100
Re: IE9 is not a friend... Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2012-12-04 16:12 +0100
Re: IE9 is not a friend... Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-12-03 23:15 +0100
Re: IE9 is not a friend... "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2012-12-03 23:15 +0200
| From | justaguy <lichunshen84@gmail.com> |
|---|---|
| Date | 2012-12-03 13:04 -0800 |
| Subject | IE9 is not a friend... |
| Message-ID | <6de7edc4-756c-40a1-ae6b-98ba94062284@m13g2000vbd.googlegroups.com> |
Hi,
Here's a simple js function.
// detect if any of 4 fields is empty before data entry in field 5
function haveFour() {
var fourFields = ['rep','contact','Market_Segment','pricing'];
for (i=0; i<4; i++) {
if (document.getElementById(fourFields[i]).value=='') {
alert('Please fill in '+fourFields[i] + ' field');
return;
}
}
}
However, it works as designed for Chrome 23, Firefox 16
but it fails with IE9. All on Windows 7.
Any idea as to the reason of failing IE9?
Thanks in advance.
[toc] | [next] | [standalone]
| From | Andrew Poulos <ap_prog@hotmail.com> |
|---|---|
| Date | 2012-12-04 08:10 +1100 |
| Message-ID | <C6mdnSBWLPzeiCDNnZ2dnUVZ_sydnZ2d@westnet.com.au> |
| In reply to | #17432 |
On 4/12/2012 8:04 AM, justaguy wrote:
> Hi,
>
> Here's a simple js function.
>
> // detect if any of 4 fields is empty before data entry in field 5
> function haveFour() {
> var fourFields = ['rep','contact','Market_Segment','pricing'];
> for (i=0; i<4; i++) {
> if (document.getElementById(fourFields[i]).value=='') {
> alert('Please fill in '+fourFields[i] + ' field');
> return;
> }
> }
> }
>
> However, it works as designed for Chrome 23, Firefox 16
> but it fails with IE9. All on Windows 7.
> Any idea as to the reason of failing IE9?
What about testing for
if (!document.getElementById(fourFields[i]).value.length) {
instead? Also I'd put 'i' in with 'var' ie
var i, fourFields...
and add
var len = fourFields.length;
for (i = 0; i < len; i++) {
We need to see the HTML to know what might be going awry.
Andrew Poulos
[toc] | [prev] | [next] | [standalone]
| From | Cezary Tomczyk <cezary.tomczyk@gmail.com> |
|---|---|
| Date | 2012-12-03 22:41 +0100 |
| Message-ID | <k9j69b$gdb$1@speranza.aioe.org> |
| In reply to | #17433 |
W dniu 2012-12-03 22:10, Andrew Poulos pisze:
[...]
> What about testing for
> if (!document.getElementById(fourFields[i]).value.length) {
> instead? Also I'd put 'i' in with 'var' ie
> var i, fourFields...
> and add
> var len = fourFields.length;
> for (i = 0; i < len; i++) {
document.getElementById(fourFields[i]).value.length counting also
spaces. So, if field contains only spaces then the question is: "Is it
still empty field?". From amount of characters point of view - no, field
is not empty, but for me, logically field is empty if contains only:
spaces, tab characters, white-spaces or "new line character".
Personally I use something extra (except checking length) to be sure if
field is really empty:
var isEmpty = (function(){
var notEmpty = new RegExp('[^\\t\\n\\r ]');
return function(str){
if(typeof str !=== 'string'){
return false;
}
return !notEmpty.test(str);
}
}());
--
Cezary Tomczyk
http://www.ctomczyk.pl/
[toc] | [prev] | [next] | [standalone]
| From | justaguy <lichunshen84@gmail.com> |
|---|---|
| Date | 2012-12-03 14:06 -0800 |
| Message-ID | <b65f92ab-27b9-471a-b1d1-7b1957e70f89@p17g2000vbn.googlegroups.com> |
| In reply to | #17435 |
On Dec 3, 4:41 pm, Cezary Tomczyk <cezary.tomc...@gmail.com> wrote:
> W dniu 2012-12-03 22:10, Andrew Poulos pisze:
> [...]
>
> > What about testing for
> > if (!document.getElementById(fourFields[i]).value.length) {
> > instead? Also I'd put 'i' in with 'var' ie
> > var i, fourFields...
> > and add
> > var len = fourFields.length;
> > for (i = 0; i < len; i++) {
>
> document.getElementById(fourFields[i]).value.length counting also
> spaces. So, if field contains only spaces then the question is: "Is it
> still empty field?". From amount of characters point of view - no, field
> is not empty, but for me, logically field is empty if contains only:
> spaces, tab characters, white-spaces or "new line character".
>
> Personally I use something extra (except checking length) to be sure if
> field is really empty:
>
> var isEmpty = (function(){
> var notEmpty = new RegExp('[^\\t\\n\\r ]');
>
> return function(str){
> if(typeof str !=== 'string'){
> return false;
> }
> return !notEmpty.test(str);
> }
>
> }());
>
> --
> Cezary Tomczykhttp://www.ctomczyk.pl/
Thank you all for your input.
and @Andrew Poulos,
"
We need to see the HTML to know what might be going awry.
"
spot on!
Yeah, I should have mentioned that it's SELECT element for each these
four elements.
So, most likely IE is expecting something like
selectElementObject.options[selectedIndex].value
Will try the code and update here... Again thanks.
[toc] | [prev] | [next] | [standalone]
| From | justaguy <lichunshen84@gmail.com> |
|---|---|
| Date | 2012-12-03 14:27 -0800 |
| Message-ID | <7501d881-dd14-4f80-a1b0-3c6ac5bb6668@s14g2000vba.googlegroups.com> |
| In reply to | #17437 |
On Dec 3, 5:06 pm, justaguy <lichunshe...@gmail.com> wrote:
> On Dec 3, 4:41 pm, Cezary Tomczyk <cezary.tomc...@gmail.com> wrote:
>
>
>
>
>
>
>
>
>
> > W dniu 2012-12-03 22:10, Andrew Poulos pisze:
> > [...]
>
> > > What about testing for
> > > if (!document.getElementById(fourFields[i]).value.length) {
> > > instead? Also I'd put 'i' in with 'var' ie
> > > var i, fourFields...
> > > and add
> > > var len = fourFields.length;
> > > for (i = 0; i < len; i++) {
>
> > document.getElementById(fourFields[i]).value.length counting also
> > spaces. So, if field contains only spaces then the question is: "Is it
> > still empty field?". From amount of characters point of view - no, field
> > is not empty, but for me, logically field is empty if contains only:
> > spaces, tab characters, white-spaces or "new line character".
>
> > Personally I use something extra (except checking length) to be sure if
> > field is really empty:
>
> > var isEmpty = (function(){
> > var notEmpty = new RegExp('[^\\t\\n\\r ]');
>
> > return function(str){
> > if(typeof str !=== 'string'){
> > return false;
> > }
> > return !notEmpty.test(str);
> > }
>
> > }());
>
> > --
> > Cezary Tomczykhttp://www.ctomczyk.pl/
>
> Thank you all for your input.
>
> and @Andrew Poulos,
> "
> We need to see the HTML to know what might be going awry.
> "
> spot on!
>
> Yeah, I should have mentioned that it's SELECT element for each these
> four elements.
> So, most likely IE is expecting something like
> selectElementObject.options[selectedIndex].value
>
> Will try the code and update here... Again thanks.
Ahe, and I find IE9 fails with a jQuery class call for autocomplete as
well while Chrome 23, Firefox 16 and even Safari 5 is just fine, I
have to abandon IE for this app for now...
[toc] | [prev] | [next] | [standalone]
| From | Christoph Becker <cmbecker69@gmx.de> |
|---|---|
| Date | 2012-12-04 15:05 +0100 |
| Message-ID | <k9kvs3$fbh$1@speranza.aioe.org> |
| In reply to | #17437 |
justaguy wrote: > Yeah, I should have mentioned that it's SELECT element for each these > four elements. > So, most likely IE is expecting something like > selectElementObject.options[selectedIndex].value AFAIK your code will work in IE, if you explicitely declare a "value" attribute for each "option" element. -- Christoph M. Becker
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2012-12-03 23:20 +0100 |
| Message-ID | <67753241.vmHCXkPt3z@PointedEars.de> |
| In reply to | #17435 |
Cezary Tomczyk wrote:
> Personally I use something extra (except checking length) to be sure if
> field is really empty:
>
> var isEmpty = (function(){
> var notEmpty = new RegExp('[^\\t\\n\\r ]');
var notEmpty = /\S/;
> return function(str){
> if(typeof str !=== 'string'){
> return false;
> }
> return !notEmpty.test(str);
> }
RegExp.prototype.test() converts its argument to String. Therefore:
return function (str) {
return !notEmpty.test(str);
};
> }());
… with which the function isEmpty() likely vanishes in a puff of logic.
PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
[toc] | [prev] | [next] | [standalone]
| From | Cezary Tomczyk <cezary.tomczyk@gmail.com> |
|---|---|
| Date | 2012-12-03 23:41 +0100 |
| Message-ID | <k9j9qb$p1p$1@speranza.aioe.org> |
| In reply to | #17439 |
W dniu 2012-12-03 23:20, Thomas 'PointedEars' Lahn pisze:
> Cezary Tomczyk wrote:
>
[...]
> var notEmpty = /\S/;
[...]
> RegExp.prototype.test() converts its argument to String. Therefore:
Good to know. Then I do not need to check if arguments is a string.
> return function (str) {
> return !notEmpty.test(str);
> };
>
>> }());
>
> … with which the function isEmpty() likely vanishes in a puff of logic.
Nice. I need update my code too :-)
--
Cezary Tomczyk
http://www.ctomczyk.pl/
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2012-12-04 15:23 +0100 |
| Message-ID | <3110977.jARfqFyjoq@PointedEars.de> |
| In reply to | #17441 |
Cezary Tomczyk wrote: > Nice. I need update my code too :-) It should also be noted that there is no “!===” operator. The strict does- not-equal operator is “!==” (ES 5.1, §11.9.5). PointedEars -- Anyone who slaps a 'this page is best viewed with Browser X' label on a Web page appears to be yearning for the bad old days, before the Web, when you had very little chance of reading a document written on another computer, another word processor, or another network. -- Tim Berners-Lee
[toc] | [prev] | [next] | [standalone]
| From | Cezary Tomczyk <cezary.tomczyk@gmail.com> |
|---|---|
| Date | 2012-12-04 16:12 +0100 |
| Message-ID | <k9l3s9$q1c$1@speranza.aioe.org> |
| In reply to | #17455 |
W dniu 2012-12-04 15:23, Thomas 'PointedEars' Lahn pisze: > It should also be noted that there is no “!===” operator. The strict does- > not-equal operator is “!==” (ES 5.1, §11.9.5). Absolutely. My typo error. -- Cezary Tomczyk http://www.ctomczyk.pl/
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2012-12-03 23:15 +0100 |
| Message-ID | <2191909.4EKZz3fc86@PointedEars.de> |
| In reply to | #17433 |
Andrew Poulos wrote:
> On 4/12/2012 8:04 AM, justaguy wrote:
>> Here's a simple js function.
>>
>> // detect if any of 4 fields is empty before data entry in field 5
>> function haveFour() {
>> var fourFields = ['rep','contact','Market_Segment','pricing'];
>> for (i=0; i<4; i++) {
>> if (document.getElementById(fourFields[i]).value=='') {
>> alert('Please fill in '+fourFields[i] + ' field');
>> return;
>> }
>> }
>> }
>>
>> However, it works as designed for Chrome 23, Firefox 16
>> but it fails with IE9. All on Windows 7.
>> Any idea as to the reason of failing IE9?
>
> What about testing for
> if (!document.getElementById(fourFields[i]).value.length) {
> instead?
That would be unnecessarily cryptic, error-prone and comparably inefficient
on top of the already inefficient approach.
> Also I'd put 'i' in with 'var' ie
> var i, fourFields...
> and add
> var len = fourFields.length;
> for (i = 0; i < len; i++) {
Or
var fourFields = …;
for (var i = 0, len = fourFields.length; i < len; i++)
{
> We need to see the HTML to know what might be going awry.
More important, we need to know their definition of an "empty field" and
"fails".
PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
[toc] | [prev] | [next] | [standalone]
| From | "Jukka K. Korpela" <jkorpela@cs.tut.fi> |
|---|---|
| Date | 2012-12-03 23:15 +0200 |
| Message-ID | <k9j4qa$4q0$1@dont-email.me> |
| In reply to | #17432 |
2012-12-03 23:04, justaguy wrote: > Here's a simple js function. Works fine (after I took the trouble of constructing a minimal test document around it, since you did not bother doing that). > Any idea as to the reason of failing IE9? The problem is elsewhere in your code. Let me see... yep, line 617. -- Yucca, http://www.cs.tut.fi/~jkorpela/
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web