Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #17438
| Message-ID | <2191909.4EKZz3fc86@PointedEars.de> (permalink) |
|---|---|
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
| Organization | PointedEars Software (PES) |
| Date | 2012-12-03 23:15 +0100 |
| Subject | Re: IE9 is not a friend... |
| Newsgroups | comp.lang.javascript |
| References | <6de7edc4-756c-40a1-ae6b-98ba94062284@m13g2000vbd.googlegroups.com> <C6mdnSBWLPzeiCDNnZ2dnUVZ_sydnZ2d@westnet.com.au> |
| Followup-To | comp.lang.javascript |
Followups directed to: comp.lang.javascript
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
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
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
csiph-web