On IE8 (not on IE9 or Safari) I get an error
this.text_array is null or not an object
for this line
`if( this.text_array[element].value === '' )`
for this object -
/**
* JClass - Text
*/
var Text = function( form_name )
{
this.text_array = document.forms[form_name].elements;
};
Text.prototype.patterns =
{
prefix_url: /^(http:)|(https:)\/\//,
url: /^.{1,2048}$/,
tweet: /^.{1,40}$/,
title: /^.{1,32}$/,
name: /^.{1,64}$/,
email: /^.{1,64}@.{1,255}$/,
pass: /^.{6,20}$/
};
Text.prototype.checkPattern = function( type )
{
return this.patterns[type].exec( this.text_array[type].value );
};
Text.prototype.checkUrlAdd = function( type )
{
return this.patterns[type].exec( this.text_array.url.value );
};
Text.prototype.checkSameEmail = function()
{
return ( (this.text_array.email.value) === (this.text_array.email1.value) );
};
Text.prototype.checkEmpty = function()
{
var element;
for ( element in this.text_array )
{
if( this.text_array[element].value === '' )
{
return 0;
}
}
return 1;
};
Not sure where to begin troubleshooting this. I guess I could start by hard coding the element object...that would eliminate the DOM Pull as a suspect. I could continue in this way...but I don't have IE8 available right now. Trial and Error unless someone has a bit of insight.
Related SO
for in vs. for
To start your debugging, use console.log(this.text_array); in relevant places.
I can only assume it's caused by this not being set right by the browser. In this case, start your checkEmpty function with var that = this; and use that instead of this through it.
Ended up using
document.getElementById()
for form access as a quick solution to fix the problem. Did not have time to troubleshoot further per suggestions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With