• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

[$repeatCounter] for jQuery

Status
Not open for further replies.

premierhw

Member
Hi folks,

I need a script which shows up alert after the validation.

I'm trying to use [$repeatCounter] with jQuery for the validation of repeat tables however
it dosn't work. (Is this placeholder for only php?)

Code:
$("[id^=join___5___form_10_repeat___valtwo]").on("blur", function() {
  var valone = $('#join___5___form_10_repeat___valone_[$repeatCounter]').val();
  var valtwo = $('#join___5___form_10_repeat___valtwo_[$repeatCounter]').val();
 
  if( valone < valtwo ) {
  alert("Error msg");
  }
});

Notes: [$repeatCounter] in jQuery code should be the same number when the validation occurs.


=======================================
Additional Information:

I also tried to use php validation instead of jQuery but the alert didn't show up.

PHP:
$one= $formModel->getElementData('form_10_repeat___valone', true, 0);
$two = $formModel->getElementData('form_10_repeat___valtwo', true, 0);
 
if(isset($one)&&isset($two)) {
    echo ($one[$repeatCounter] < $two [$repeatCounter]) ? '<script>alert("It\'s wrong!")</script>': 'Its fine!';
}



Please let me know if anyone has any solution.
Thank you in advance.
 
Hi rob,

Thank you for a reply.
My colleague and I had a look the page which you gave me, and it works fine!

Here is a solution...

Firstly I created a 'form_x.js' file to 'component > com_fabrik > js folder' as the instruction guide.

Code:
Fabrik.addEvent('fabrik.form.group.duplicate.end', function (form, event) {
    var groupId = 1;
    var repeatMax = form.repeatGroupMarkers[groupId];
    var valone = form.formElements['join___5___form_10_repeat___valone_'+(repeatMax-1)].getValue();
    var valtwo = form.formElements['join___5___form_10_repeat___valtwo_'+(repeatMax-1)].getValue();
 
    if( valone< valtwo ) {
        alert("Error msg");
    }
});

Thank you for your help.
premierhw
 
  • Like
Reactions: rob
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top