[jQuery] Re: Why would this code cause this error in IE?

2009-09-12 Thread MorningZ

Wow, that code could be a LOT easier

var Validations = {
   streetNumber: true,
   streetName: true,
   city: true,
   state: true,
   bedrooms: true,
   fullBaths: true,
   rent: true,
   securityDeposit: true,
   AllValid = function() {
return this.streetNumber &&
this.streetName &&
this.city &&
this.state &&
this.bedrooms &&
this.fullBaths &&
this.rent &&
this.securityDeposit
   }
};


$('#streetNumber').livequery('blur', function() {

 if (this.value.length == 0)
{ $('#' + this.id + '_requiredError').fadeIn(250);
  $(this).css('backgroundColor', '#ffeaea');
 IsValid.streetNumber = false;
  }
 else
{ $('#' + this.id + '_requiredError').fadeOut(250);
  $(this).css('backgroundColor', '#fff');
 IsValid.streetNumber = true;
   }
  ValidateForm();

});


and whenever you need to ask "are all valid"... Validations.AllValid
will tell you true or false

That code for the validation could be cleaned up a lot more too, but
for sake of helping the original issue of not stomping on IE's issues

And you're using strings for boolean checks all over the place, use
boolean values it's less typing  :-)



On Sep 12, 1:56 pm, "Rick Faircloth"  wrote:
> 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');
>     

[jQuery] Re: Why would this code cause this error in IE?

2009-09-12 Thread Rick Faircloth

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
 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,
&

[jQuery] Re: Why would this code cause this error in IE?

2009-09-12 Thread Rick Faircloth

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
 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
>  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

>> 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.




[jQuery] Re: Why would this code cause this error in IE?

2009-09-12 Thread Mike McNally

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
 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
>  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 
>> 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.


[jQuery] Re: Why would this code cause this error in IE?

2009-09-12 Thread Rick Faircloth

But...now IE throws an error again:
"Object doesn't support this property or method"

What's the solution?


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


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
 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 
> 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.






[jQuery] Re: Why would this code cause this error in IE?

2009-09-12 Thread Rick Faircloth

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
 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 
> 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.




[jQuery] Re: Why would this code cause this error in IE?

2009-09-12 Thread Mike McNally

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
 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 
> 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.


[jQuery] Re: Why would this code cause this error in IE?

2009-09-12 Thread Rick Faircloth
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 
<http://www.brainyquote.com/quotes/authors/c/charles_de_gaulle.html>   - "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  
wrote:

Code:

 

   $(document).ready(function() {

   

  streetNumber = 'valid';

  streetName  = 'valid';

  city = 'valid';

  state= 'valid';

  bedrooms = 'valid';

  fullBaths= 'valid';

  rent = 'valid';

  securityDeposit  = 'valid';

 

   });

 



[jQuery] Re: Why would this code cause this error in IE?

2009-09-12 Thread Dhruva Sagar
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 wrote:

>  Code:
>
>
>
>$(document).ready(function() {
>
>
>
>   streetNumber = 'valid';
>
>   streetName  = 'valid';
>
>   city = 'valid';
>
>   state= 'valid';
>
>   bedrooms = 'valid';
>
>   fullBaths= 'valid';
>
>   rent = 'valid';
>
>   securityDeposit  = 'valid';
>
>
>
>});
>
>
>
> Error:
>
>
>
> “Object doesn’t support this property or method”
>
>
>
> This doesn’t cause an error in FF.
>
>
>
> Thoughts?
>
>
>
> Thanks,
>
>
>
> Rick
>
>
>
> *
> ---
> *
>
> *"Those who hammer their guns into plows will plow for those who do not."
> - Thomas Jefferson*
>
>
>