So i created a form which has some xtra input fields shown/hidden depending on an user's input. But how can i use a correct javascript validation for this form. At the moment the validation only works: A/ when the extra input fields are hidden (at start) Furthermore, i like to validate the xtra input fields if they are shown. If i just validate the inputfield it seems to work, but when i hide the input fields it still want to validate the input fields?? btw this code i am using for show/hide function hide(id) { document.getElementById(id).style.visibility = 'hidden'; document.getElementById(id).style.display = 'none'; } function show(id) { document.getElementById(id).style.visibility = 'visible'; document.getElementById(id).style.display = 'block'; } Code (markup): Any advice
just do a simple check to see if the element is visible... if (document.getElementById(id).style.visibility == 'visible') { do validation... } Code (markup):