[$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

No members online now.
Back
Top