Forums

[SOLVED] - Internet Explorer skipping javascript validation

awgcas 10 Feb, 2013
Hi to all,
I have a problem using Internet Explorer (v.8 +) with a text box that has to be required or not depending on the value of a drop-down menu.

Text box has id = "ans_id" and drop-down menu has id = "status".

I have inserted in a "Load JS" the following code:

window.addEvent('domready', function() {
  $('status').addEvent('change', function() {
    if ( $('status').value == 'some-value' ) {
      $('ans_id').setProperty('required', 'required');
        } else {
           $('ans_id').setProperty('required');
        }
      });
    });


Everything works fine at least with Firefox and Chrome, but using Internet Explorer (as usual...) the field "ans_id" does not become required, so users are able to submit without filling the text box.

What can I try to make it working???

Thanks in advance
Alessandro
GreyHead 10 Feb, 2013
Hi awgcas,

Please post a link to the form so I can take a quick look.

Bob
GreyHead 11 Feb, 2013
Hi Alessandro,

The 'required' attribute is a new HTML5 attribute. As far as I can see it isn't supported in IE8 or Safari and it's also not used by ChronoForms.

See the 'Field validation' entry on this test page .

Bob
awgcas 13 Feb, 2013
Ok, thank you very much. I solved the problem slightly changing the form logic.
I set the text box mandatory, and with the same code changed it to disabled if the value selected in the drop-down menu does not match.
In this way it works.


window.addEvent('domready', function() {
  $('status').addEvent('change', function() {
    if ( $('status').value == 'some-value' ) {
      $('ans_id').setProperty('disabled');
        } else {
           $('ans_id').setProperty('disabled', 'disabled');
        }
      });
    });


Thanks again.
Alessandro
This topic is locked and no more replies can be posted.