I'm working on a verification program for a form, I have the code for how to verify each value completed but I'm trying to put the code into a function to make it reusable.
The way I have the code written right now if the user enters a value that is not suitable it changes the visibility of a span tag from 'hidden' to 'visible'.
This works fine if I tell it exactly where to go e.g. tagname.style.visibility = 'visible'.
However when you pass tagname.style.visibility (or any other property It seems) as an argument to a function it only passes the value and not the referance to the variable itself.
Is there any easy way to pass the visibility property like a referance so that I can set the style.visibility property of a tag within the function without explicitly stating which tag but using the arguement passed to the function?
Here is the code I have written you may be able to get a better idea of what I'm trying to do by looking at it:
function verifyInt(intValue, errorVisability) {
if ((intValue != "") && ((isNaN(intValue)) || intValue != parseInt(intValue))) {
errorVisability = 'visible';
}
else {
errorVisability = 'hidden';
}
}
verifyInt(document.form1.dive.value, dive_error.style.visibility);
Thank you in advance for any help offered.
The way I have the code written right now if the user enters a value that is not suitable it changes the visibility of a span tag from 'hidden' to 'visible'.
This works fine if I tell it exactly where to go e.g. tagname.style.visibility = 'visible'.
However when you pass tagname.style.visibility (or any other property It seems) as an argument to a function it only passes the value and not the referance to the variable itself.
Is there any easy way to pass the visibility property like a referance so that I can set the style.visibility property of a tag within the function without explicitly stating which tag but using the arguement passed to the function?
Here is the code I have written you may be able to get a better idea of what I'm trying to do by looking at it:
function verifyInt(intValue, errorVisability) {
if ((intValue != "") && ((isNaN(intValue)) || intValue != parseInt(intValue))) {
errorVisability = 'visible';
}
else {
errorVisability = 'hidden';
}
}
verifyInt(document.form1.dive.value, dive_error.style.visibility);
Thank you in advance for any help offered.