Forums

Fix Validation JS in the head

craigie2204 18 Mar, 2014
Hi

I am wondering if anyone can help me. Just now I am receiving a JavaScript error, which I believe is stopping my form from submitting. ( I can submit the form fine in test mode but when implemented in my design it doesn't send ) The error is to do with the js that chronoForms adds to the <head> tag.

	window.addEvent('domready', function() {
				document.id('chronoform_Contact_Form').addClass('hasValidation');
				formCheck_Contact_Form = new FormCheckMax('chronoform_Contact_Form', {
					onValidateSuccess: function(){},
					display : {
						showErrors : 0,
						errorsLocation: 3					}
				});										
			});


I recieve the error "Cannot Call Method 'addClass' of null" I think this is because the JS is loading before the element has loaded. Is there anyway I can edit this file to maybe add "jQuery(document).ready(function() " to ensure the element has loaded.

Thank you
GreyHead 18 Mar, 2014
Hi craigie2204,

The first line of the code you posted is the MooTools equivalent of your jQuery code.

Which line of JavaScript does the error come from?

Bob
craigie2204 18 Mar, 2014
Hi Bob

Thanks for you reply. The error comes from Javascript which is loaded in to the head tag with <script></script>

//<![CDATA[
			window.addEvent('domready', function() {
				document.id('chronoform_Contact_Form').addClass('hasValidation');
				formCheck_Contact_Form = new FormCheckMax('chronoform_Contact_Form', {
					onValidateSuccess: function(){},
					display : {
						showErrors : 0,
						errorsLocation: 3					}
				});										
			});
			
//]]>
jQuery(document).ready(function()
				{
					jQuery('.hasTooltip').tooltip({});
				});
  


The error comes from line 2
				document.id('chronoform_Contact_Form').addClass('hasValidation');


I have turned off validation in the form wizard but this script still appears in the head.

Thanks
GreyHead 18 Mar, 2014
Hi craigie2204,

It sounds as though the form id isn't set . . .Please post a link to the form so I can take a quick look.

Bob
craigie2204 18 Mar, 2014
Hi

Here is the link http://tinyurl.com/o9wby87

Thanks
GreyHead 18 Mar, 2014
Hi craigie2204,

The whole page appears to be embedded in <form> tags from some other form:
<form name="aspnetForm" action="" method="post" onsubmit="if (window.WebForm_OnSubmit) { return WebForm_OnSubmit(); } else { return true; }" id="aspnetForm">

That looks wrong to me. Nested <form> tags are not permitted in HTML so the browser (Chrome in my case) is ignoring the ChronoForm <form> tags and hence the id does not exist.

Bob
craigie2204 18 Mar, 2014
Thanks! It was a piece of legacy code from a template I am trying to move over to Joomla, rookie mistake. It works now.

I shall buy you a coffee!!
henkdepoema 19 May, 2014
Exactly the same error here, but no 'legacy code' to fix ;-). Loading my form by the plugin didn't work, but loading it as a module, in combination with Modules Anywhere, shows only the Powered By Chronoforms-line but no form at al. While debugging I get the same Javascript error in the same line. I don't know what I am missing!
GreyHead 19 May, 2014
Hi henkdepoema,

Please post a link to the form so I can take a quick look.

Bob
GreyHead 19 May, 2014
Hi henkdepoema,

In this case the error is because there is no form to validate. I think that is because you are using Modules Anywhere to show the form instead of using the ChronoForms plug-in. If I look at the form page then the validation is working OK.

Bob
Max_admin 19 May, 2014
Hi,

If the form is only displaying the "power by" line then you need to add the "Show HTML" action to the "on load" event if you use the regular wizard, or use the "simple form".

Regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
henkdepoema 21 May, 2014
Thanks for the answers.
@admin: the Show HTML action is added and the form works fine when clicking Frontend view or loading it by a menu-item.

I kept on struggling with the validation error, even tried to apply GreyHead's NoConflict() solution. But nothing worked, my form works only error-free when accessed by a menu-item. I decided to switch to ChronoForms v5. Weird enough, the v5-plugin doesn't work either (neccessary files are loaded and no errors this time, but it only shows {chronoforms5}wensenboekje{/chronoforms5} ), but loading the form as a module does!
Using Modules Anywhere gives me finally the opportunity to load my form in an article! There are some issues, but I'm getting off-topic now.
Max_admin 21 May, 2014
The v5 plugin should work fine, it may have been just a cache issue, you can test again with the cache disabled!

Regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
henkdepoema 21 May, 2014
Tested with all possible caching settings, still no luck. I also checked for <p> tags and what not, magic quotes are disabled, the plugin is enabled, it's the right version... I will check if it's still not working when using another template.
Max_admin 21 May, 2014
the form is displaying in both templates!
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
henkdepoema 21 May, 2014
You're right, my bad. The first link shows the form as a module, using Modules Anywhere.
This page tries to load the plugin in the actual template: http://goo.gl/XZlufl
Max_admin 21 May, 2014
Are you sure the v5 plugin is enabled ?
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
henkdepoema 21 May, 2014
Very sure, if only because the plugin works in a default template ;-)
Max_admin 24 May, 2014
Ok, maybe try to clear the template cache ? or does the template have some settings to disable the plugins ? or some mis-configuration ? you may try to ask the template developer for hints ?
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
This topic is locked and no more replies can be posted.