Forums

Next field to show/hide based on dropdown

Lara_Shadow 22 Jul, 2010
Hello All,

I have drop down for with Yes,No. Next is a text box.
Text box should be required only if "Yes" is selected from the drop down.
I have used class="cf_inputbox required validate-digits" on next text box.
I am using a function on onchange of drop down to show or hide text box.
I am able to hide/show (also removing/adding class to elements for validations) text box.
But when I submit the form nothing happens as Live validations are still forces to fill the text box. They are adding automatically the class " LV_invalid_field"
How can I disable the live validations on the text box if NO is selected from the drop down.

I am using this function on onchange
function heloc_chk()
{
var heloc = document.getElementById("text_18");
if(document.getElementById("select_17").value == 0)
{
heloc.className='';
document.getElementById("heloc_div").style.display='none';
}
if(document.getElementById("select_17").value == 1)
{
heloc.className='cf_inputbox required validate-digits';
document.getElementById("heloc_div").style.display='';
}
}
GreyHead 29 Aug, 2010
Hi Lara_shadow,

Sorry to be so long in replying. I've found a bunch of posts I saved earlier.

You should be able to adapt the code from this post to work here. Mackirony has also asked this question in the last few days and hopefully will post his solution.

Bob
This topic is locked and no more replies can be posted.