javascript validation causes this.element is null

digiweb 19 Nov, 2007
Let me just say first that this is an amazing component.

I created a form according to the validation tutorial. There is a bug in the form creation and another upon loading the page.

This code is added to the HTML:
var valid = new Validation('my_form', {immediate : true, onFormValidate : formCallback});

And this is added to the Form Tag attachment:
"id=my_form"

ChronoForm creates two id's for the form:
<form name="ChronoContact_test_form" id="ChronoContact_test_form" method="post" action="index.php?option=com_chronocontact&task=send&chronoformname=test_form" id="my_form">

The "my_form" id is ignored at validation because the form's id is also "ChronoContact_test_form."

If I change the Form Tag to
"id=ChronoContact_test_form"

the form now has two id's of "id=ChronoContact_test_form"
and the validation works but the form displays an error on loading:

Line 9
Char 186
Error 'this.element' is null or not an object
code 0
URL http://candogo.com/index.php?option=com_chronocontact&chronoformname=test_form

"this.element" is referenced in components/com_chronocontact/js/ effects.js and prototype.js

I get straightforward errors in IE. In firefox error console I get an error I'm pretty sure is just a red herring:

Error: $$.shared has no properties
Source File: http://candogo.com/mambots/system/jceutils/jscripts/mootools.js
Line: 55

This feels like a DOM IE getElementBySomethingICantCauseImIE type of bug but that would not explain why Firefox cascades it over to Mootools.

Any ideas? I'm way over my head javascript wise.

thank you!!
Max_admin 19 Nov, 2007
Hi digiweb,

Chronoforms should add only 1 id which will be : id="ChronoContact_test_form"

assuming your form name is test_form!

Do you have any text in the form tag attachment field ?
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
GreyHead 21 Nov, 2007
Hi digiweb,

Apologies for the out of date tutorial. I've moved it up my to-do list to bring them up to date.

I do get that error on IE7 - the page loads OK but the Validation doesn't work. But I can't identify the line 124 reference (maybe because of CR / LF+CR issues). You do have a lot of JavaScript on the page and I wonder if there isn't a conflict somewhere.

Bob<br><br>Post edited by: GreyHead, at: 2007/11/21 12:01
digiweb 21 Nov, 2007
that's ok. it's a learning process.

You mean all that rocket theme ajax javascript? I know, it's a giant hairball. I will attempt to run chrono without any of it to see if I can produce a clean output.

thank you.
GreyHead 21 Nov, 2007
Hi digiweb,

See the list, you've got some big loads from Joomla (the MooTools library) and from ChronoForms (the Prototype library), plus the Rocket stuff plus some script embedded in the page.

Nothing unusual about this but it does make debugging JS errors tricky!

Hopefully at some point ChronoForms will switch to use the MooTools library for J 1.5.

Bob

javascript validation causes this.element is null image 1<br><br>Post edited by: GreyHead, at: 2007/11/21 12:08
Mizpah 21 Nov, 2007
Not sure if you are aware, or if this is relevent to you digi, but the rocket theme .js in the templates is in the process of being updated to the latest mootools (at least I think it is for versitiltiy) - as such you may not want to play with the .js too much yet!

Cheers,

Miz
digiweb 22 Nov, 2007
ok! I'll keep my eye on rocket theme.
This topic is locked and no more replies can be posted.