Javascript error: 0.type is null of not an object

Associate
Joined
2 Aug 2005
Posts
680
Hi,

I've added a form validation script to my form but it's not working and this is the error:

'0.type' is null or not an object

here's line 60 of the code where the error appears to be happening:

Code:
  if (!o.type&&o.length>0&&o[0].type=='radio'){
          at = a[i].match(/(.*)\[(\d+)\].*/i);

I don't have much knowledge of javascript and this code is generated from a dreamweaver plugin. I have used this plugin before and it's work, just not with this form for some reason. Any advice would be appreciated :)
 
Hi,

I can't help you much without seeing the entire script, but from what you've posted this is what I'm thinking:

!o.type&&o.length>0&&o[0].type

splits to

o.type
o.length>0
o[0].type

and I don't think the parser likes the 3rd bit. Try shoving them all into variables and then sticking the var references into the IF statement:

var value1 = o.type;
var value2 = o.length;
var value3 = o[0].type;


if (!value1&&value2>0&&value3=='radio'){
at = a.match(/(.*)\[(\d+)\].*/i);
}

See if that helps at all... good luck :D

Jon
 
Last edited:
Back
Top Bottom