Shopping news - Free Music Downloads - Just Holden Commodores - Wordpress Themes - Travel news

PDA

View Full Version : show/hide some input fields and form validation???


123GoToAndPlay
Aug 10th 2007, 1:48 am
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';
}


Any advice

Drag Racer
Aug 10th 2007, 9:49 pm
just do a simple check to see if the element is visible...

if (document.getElementById(id).style.visibility == 'visible') {
do validation...
}