Buy Now
Sign in

field validationrules searched in container

emmexx , December 04 2017
E
emmexx
In a rather complex form I enable/disable, enable/disable validation based on the values of a couple of checkboxes.
I set one field (a textarea) as Required and validation Disabled.
I add an event to a checkbox that enables validation using as identifier a class. I added the class in the Container class property of the field (the textarea).
When I check the checkbox nothing happens, the validation is not applied.

I checked the js code that cf adds to the form, in particular the following lines:
if(jQuery.inArray('enable_validation', event.action) > -1){
  if(event_target_one.data('validationrules')){
    var vrules = event_target_one.data('validationrules'); //*** this line never runs
    vrules['disabled'] = 0;
    event_target_one.data('validationrules', vrules);
    
    $.G2.forms.initializeForm(Form);
  }
}


The line that I marked in blue is never run.
If I understand correctly the code, the validation rules are searched for in the container, not in the textarea.

Is that correct?

maxx
E
emmexx
I found out that a similar problem happens with the enable or disable event. When the Element(s) identifier property is a class, the js code tries to remove the disabled class from the container, not from the input element:
if(jQuery.inArray('enable', event.action) > -1){
  target_element.removeClass('disabled');
  event_target.prop('disabled', false);
  if(event_target.prop('tagName') == 'SELECT'){
    event_target.parent('.ui.dropdown').removeClass('disabled');
  }
}


Am I using the class feature the wrong way?

maxx