?
avatar deepanshu-jha
deepanshu-jha
17 Oct 2014

The custom validation rules for the form fields are not working as expected soon after the release of joomla! 3.3.3 & are throwing several errors in the console. The same set of handlers & syntax worked fine untill the joomla! 3.2.x versions. The successive versions after the release of 3.3.3 are also facing the similar problems. I tried looking into the issue & found that there is a drastic change in the file 'validate.js'(located in media\system\js) in 3.3.3 & above versions. And these changes have led to following problems:

-> The joomla! docs provide the syntax to write custom validation rules which work properly only untill 3.2.x versions.So, there is a need to re-write the documentation for the same.

-> The components & other utilities in joomla! administrator which are using custom form validation rules will have to re-work on the validation rules.

P.S. - May be this issue has something to do with the deprecation of mootools liabrary & gradually shifting towards jQuery as the file validate.js surely reflects it after 3.3.3 when compared with earlier versions.

Steps to reproduce the issue

create a validation rule using document.formvalidator.setHandler

Expected result

It should work fine with joomla! 3.3.3 & successive versions.

Actual result

It works properly only untill joomla! 3.2.x.

Votes

# of Users Experiencing Issue
1/1
Average Importance Score
5.00

avatar deepanshu-jha deepanshu-jha - open - 17 Oct 2014
avatar deepanshu-jha deepanshu-jha - change - 17 Oct 2014
The description was changed
avatar Harmageddon
Harmageddon - comment - 17 Oct 2014

Hello and thank you for your report!

Could you please add a more precise instruction on how to reproduce the issue (e.g. with code attached that worked before and is broken now)? I just looked into the file history of validate.js. The last change was on April 18, before the release of 3.3.0.

This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/4736.

avatar deepanshu-jha
deepanshu-jha - comment - 18 Oct 2014

Thank you so much for considering my issue! I am glad to provide you with more information about the issue.
I am sorry I mentioned the incorrect version while posting this issue. I was talking about 3.2.3( also any other 3.2.x) & 3.3.3(also any other 3.3.x). I simply compared the file validate.js in two verions & found that the file has been updated in 3.3.3.

Below is a piece of code to give you a better idea about the custom validation rules which used to worked earlier. Instead of writing the full code, I am writing down certain parts of code which are enough to give you a good idea:

Note: Both the cases have been conducted in joomla! 3.3.3 & above.

CASE 1 (Did not work)


JHtml::_('behavior.formvalidation'); // for including validate.js

window.addEvent('domready', function(){
document.formvalidator.setHandler('radio', function(value) {
var publish1 = document.getElementById("publish1").checked;
var publish0 = document.getElementById("publish0").checked;

 if(publish1 != 0 || publish0 != 0){

        //some code
        return true;
 }
 else{
           //some code
        return false;
 } 

});
});


CASE 2 (Worked with a workaround)


/*
Instead of including the validate.js file from the directory (media\system\js) of 3.3.3 , I copied validate.js from joomla! 3.2.x & included it. As a result, everything worked fine again!
*/

$document = JFactory::getDocument();
$document->addCustomTag(''); // validate.js from joomla! 3.2.x version

window.addEvent('domready', function(){
document.formvalidator.setHandler('radio', function(value) {
var publish1 = document.getElementById("publish1").checked;
var publish0 = document.getElementById("publish0").checked;

 if(publish1 != 0 || publish0 != 0){

        //some code
        return true;
 }
 else{
           //some code
        return false;
 } 

});
});


I know my workaround is not a feasible solution, but it is still better to include a file than to change whole block of validation rules.

avatar deepanshu-jha deepanshu-jha - change - 18 Oct 2014
The description was changed
avatar brianteeman brianteeman - change - 3 Jan 2015
Labels Added: ?
avatar vdespa
vdespa - comment - 14 May 2015

Hi, the issue is a bit old and there are currently no update to it. Please check the documentation and create a new issues if this does not work in Joomla 3.4 or later as stated in the documentation: https://docs.joomla.org/Client-side_form_validation. Thanks for your understanding.


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/4736.

avatar vdespa vdespa - change - 14 May 2015
Status New Closed
Closed_Date 0000-00-00 00:00:00 2015-05-14 07:14:35
Closed_By vdespa
avatar vdespa
vdespa - comment - 14 May 2015

Set to "closed" on behalf of @vdespa by The JTracker Application at issues.joomla.org/joomla-cms/4736

avatar joomla-cms-bot joomla-cms-bot - close - 14 May 2015

Add a Comment

Login with GitHub to post a comment