[thelist] [JS] toLowerCase() not a function error - data types
Tom Dell'Aringa
pixelmech at yahoo.com
Wed Apr 7 10:46:03 CDT 2004
Just working on my validation and came across an odd error. I have
this code snippet:
--
validDataTypeRegEx = /_[a-zA-Z]+$/i;
validDataType = validDataTypeRegEx.exec(oElement.name);
alert(validDataType) // alerts "_isEmail"
validDataType = validDataType.toLowerCase(); <-- throws exception...
--
The last line there throws an exception:
Error: validDataType.toLowerCase is not a function (IE complains
"object doesn not support this property or method).
Apparently JS doesn't see validDataType as a string, but some other
type of data. Since exec() returns an array - it must be an array
object.
I tried using exec(oElement.name)[0] to pull the first element of the
array, but it still wouldn't work.
Does anyone know why specifying the index of the array in exec
wouldn't return a string? I kind of would rather not have to do the
string manipulation if I don't have to.
Thanks
Tom
=====
http://www.Pixelmech.com/ - read my latest blog posting!
http://www.DMXzone.com/ - JavaScript Author
http://SparklesParties.com - Princess parties for little girls!
http://www.thywordistruth.net/ - Eternal Life
"Well, my name's Dewey Oxburger. My friends call me Ox. I dont know if you've noticed, but I got a slight weight problem."
More information about the thelist
mailing list