Well...just fyi in case anyone is interested, here is the solution.

IE doesn't like global variables (I think it just applies to global
variables
and not local variables) that have the same name as element ID's.

A blog I read on this suggested adding "var" + variableName; as the
solution, which,
after initial testing, works fine:

$(document).ready(function() {
        
   var streetNumber;
   var streetName;
   var city;
   var state;
   var bedrooms;
   var fullBaths;
   var rent;
   var securityDeposit;
                                
   streetNumber          = 'valid';
   streetName            = 'valid';
   city                  = 'valid';
   state                 = 'valid';
   bedrooms              = 'valid';
   fullBaths             = 'valid';
   rent                  = 'valid';
   securityDeposit       = 'valid';
                        
});

-----Original Message-----
From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
Behalf Of Rick Faircloth
Sent: Saturday, September 12, 2009 12:29 PM
To: jquery-en@googlegroups.com
Subject: [jQuery] Re: Why would this code cause this error in IE?


Well...they're for form validation purposes.

Those variables are the form fields that I am validating.
I initially set them to valid (for updates), then as a user works with the
form fields,
upon blur of each field, I run a function which scans all fields that are
being validated to see if they are all still valid.

If they are, then the submit button is enabled.  If any of the fields are
invalid, the submit button remains or becomes disabled.

Here's the code that does that:

function ValidateForm() {
                        
     if  (   streetNumber      ==  'valid'
         &&  streetName        ==  'valid'
         &&  city              ==  'valid'
         &&  state             ==  'valid'
         &&  bedrooms          ==  'valid'
         &&  fullBaths         ==  'valid'
         &&  rent              ==  'valid'
         &&  securityDeposit   ==  'valid')
                                
         { $('#addButton').removeAttr('disabled');
           $('.validationError:visible').fadeOut(250);      }
   else
         { $('#addButton').attr('disabled', 'disabled');
           $('.validationError').fadeIn(250);               };

};

And, for an example of how an individual field is being validated:

$('#streetNumber').livequery('blur', function() {
                                
     if     (this.value.length == 0)
            { $('#' + this.id + '_requiredError').fadeIn(250);
              $(this).css('backgroundColor', '#ffeaea');
              streetNumber = 'invalid'; }
     else
            { $('#' + this.id + '_requiredError').fadeOut(250);
              $(this).css('backgroundColor', '#fff');
              streetNumber = 'valid'; };
                                        
              ValidateForm();
                                
});


This works well, except for IE not liking the variable without "var"...

And, for my edification, why are global variables frowned upon?

Suggestions?

Thanks,

Rick




-----Original Message-----
From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
Behalf Of Mike McNally
Sent: Saturday, September 12, 2009 11:53 AM
To: jquery-en@googlegroups.com
Subject: [jQuery] Re: Why would this code cause this error in IE?


Yes, that's correct.  It would probably help to know what it is that
those (apparently global) variables are, or rather where it is that
they come from (and, from curiosity, why the page would set things up
that way - global variables are as ugly in web pages as they are in
any other programming domain).


On Sat, Sep 12, 2009 at 10:47 AM, Rick Faircloth
<r...@whitestonemedia.com> wrote:
>
> Hmmm...that could explain the sudden error I just now received
> running that code that "city is not defined" and "state is not defined",
> etc.,
> when validation tries to run.
>
> I guess using "var" causes the variable to be local within that piece of
> code
> instead of applicable there and in other pieces of code that references
> those variables?
>
> Rick
>
> -----Original Message-----
> From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
> Behalf Of Mike McNally
> Sent: Saturday, September 12, 2009 9:12 AM
> To: jquery-en@googlegroups.com
> Subject: [jQuery] Re: Why would this code cause this error in IE?
>
>
> Well, putting "var" before the variables will probably make IE happy,
> but it also makes the function useless.
>
>
> On Sat, Sep 12, 2009 at 7:12 AM, Rick Faircloth
> <r...@whitestonemedia.com> wrote:
>> That did it…seems to satisfy IE that way, too.
>>
>>
>>
>> Thanks,
>>
>>
>>
>> Rick
>>
>>
>>
>> From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
>> Behalf Of Dhruva Sagar
>> Sent: Saturday, September 12, 2009 6:06 AM
>> To: jquery-en@googlegroups.com
>> Subject: [jQuery] Re: Why would this code cause this error in IE?
>>
>>
>>
>> You should use the keyword 'var' before each variable.
>>
>> Thanks & Regards,
>> Dhruva Sagar.
>>
>>
>> Charles de Gaulle  - "The better I get to know men, the more I find
myself
>> loving dogs."
>>
>> On Sat, Sep 12, 2009 at 3:33 PM, Rick Faircloth
<r...@whitestonemedia.com>
>> wrote:
>>
>> Code:
>>
>>
>>
>>        $(document).ready(function() {
>>
>>
>>
>>               streetNumber         = 'valid';
>>
>>               streetName          = 'valid';
>>
>>               city                 = 'valid';
>>
>>               state                = 'valid';
>>
>>               bedrooms             = 'valid';
>>
>>               fullBaths            = 'valid';
>>
>>               rent                 = 'valid';
>>
>>               securityDeposit      = 'valid';
>>
>>
>>
>>        });
>>
>>
>
>
>
> --
> Turtle, turtle, on the ground,
> Pink and shiny, turn around.
>
>
>



-- 
Turtle, turtle, on the ground,
Pink and shiny, turn around.




Reply via email to