Forums

Ability to stop validation on hidden fields

tidusx18 25 Oct, 2009
It would be useful to be able to stop validation on hidden fields thus allowing the form to submit. This would allow people who use forms that have fields that are only displayed if certain selections are made from drop down boxes, check boxes or other fields.

PS: This is an ongoing issue for me since upgrading from version 3.1 Stable...I have just down graded back to 3.1 stable as a quick fix.

Regards,

Daniel
nml375 25 Oct, 2009
Hi Daniel,
I believe this is quite possible to achieve with a little scripting. There's a nice guide on how to add validation on the LiveValidation homepage, you'd simply have to add another two lines or such to the code used to display/hide inputs in your form.

I'm currently on a mobile unit, so I'm not able to fetch the proper code easily right now, but I'll have a look at it once I'm back home at my workstation

/Fredrik
willson 25 Oct, 2009
Something like this (using mootools) can work:

function noBus() {
  dontDisplayById('row_transport');
  $('transporte');
  document.getElementById('transport').removeClass('required');
  document.getElementById('noTransport').checked=true; 
}

function dontDisplayById(IdValue) {
$(IdValue);
document.getElementById(IdValue).style.display = 'none';
}


The $(yada) lines are a workaround for IE - Makes the getElementById work as expected in IE.
tidusx18 25 Oct, 2009

Hi Daniel,
I believe this is quite possible to achieve with a little scripting. There's a nice guide on how to add validation on the LiveValidation homepage, you'd simply have to add another two lines or such to the code used to display/hide inputs in your form.

I'm currently on a mobile unit, so I'm not able to fetch the proper code easily right now, but I'll have a look at it once I'm back home at my workstation

/Fredrik



Fredrik,

I did find the live validation page and saw the code to disable validation on certain fields, but my form has a drop down box with about 22 options and each option displays a different combination of about 20 some fields. That's just too much mess to deal with at this time. I have to say that I tried it on a small form and it DID work though. The only problem I have was when I started trying the code with checkbox and radio button fields.

Either way, I feel that this is something that should be built in to the chrono forms system so people (like me) don't have to go in and add any code.
tidusx18 25 Oct, 2009

Something like this (using mootools) can work:

function noBus() {
  dontDisplayById('row_transport');
  $('transporte');
  document.getElementById('transport').removeClass('required');
  document.getElementById('noTransport').checked=true; 
}

function dontDisplayById(IdValue) {
$(IdValue);
document.getElementById(IdValue).style.display = 'none';
}


The $(yada) lines are a workaround for IE - Makes the getElementById work as expected in IE.




Willson,

I really don't know any JS so I don't really know what to do with the code you pasted...Thanks anyway.
This topic is locked and no more replies can be posted.