Using JQuery and form validation

petersen 30 May, 2008
There are a few threads on here about this. I'm also running JQuery on my site and want to get validation running. I guess there are 2 options:

1) Code my own validation routine in Jquery
2) Use the jQuery.noConflict method.

Now the first item could take some time (which I don't have right now) so let's look at the second.

I currently use the following in my template:

window.onload = function()
	{
		//As we load Mootools we need to handle any namespace problems
		jQuery.noConflict();
		
		...jQuery stuff...
	}


This works fine as there is a conflict between Mootools and JQuery. The code has to be run once all of the script have been loaded. The problem we have is that the Chronoforms validation is inserted into script tags half way down the page (see chronocontact.html.php). What we need to do is use the Joomla method

$document->addScript($mainframe->getCfg('live_site').'SCRIPTPATH');


..to put the code in the header of the document. However, I can't get this to work. Can one of the admins take a look at this and see if they can get it working? I keep getting a JSite::getDocument is undefined error.
GreyHead 30 May, 2008
Hi petersen,

I can take a look but at a guess the error you get is a scope problem. The ChronoForms code runs in an eval() function, I often find that I need to redeclare or reinitialise global structures. I don't know JSite or what's needed to declare it.

Bob
This topic is locked and no more replies can be posted.