View Full Version : Detect whether form field is HIDDEN or not

06-07-2004, 10:10 PM

I have a form that passes a field either as a HIDDEN variable or as variable chosen by the user, depending on answers from a previous page.

In validating the form upon submission, I want to ensure the presence of a value for this field (when the user is choosing), but I'm having trouble doing this.

My question:
Is there a way for my form validation script to determine whether this field is being passed as a HIDDEN variable or as one input by the user? Or is there a better way to accomplish this?

Many thanks,

06-07-2004, 11:18 PM
Perhaps a link for us to look at or your code...


06-08-2004, 12:09 AM
Hi again,

Well this seems to have worked, at least with IE6 & Mozilla....

function CheckForms(f){
validMessage="Please complete the following field(s):\n\n";
dataEntered = new Boolean(true)
if (f.search_tp.hidden){
if (!f.search_tp[0].checked && !f.search_tp[1].checked){
dataEntered = false;
validMessage += "Search Type\n";

Thanks for looking anyways,

06-08-2004, 01:34 AM
No, I take it back. That didn't work after all...

06-08-2004, 04:32 AM
Do you mean hidden field like this?

<input type="hidden" ... />

If yes, then this should be the solution:

if (f.search_tp.type=="hidden"){

But it seems to be a checkbox?

if (!f.search_tp[0].checked && !f.search_tp[1].checked){

Maybe you meant a hidden div or span that contains the checkbox fields.

06-08-2004, 06:10 PM
Hey thanks, glenngv!

Yea, that was the form I was referring to. And just for closure, the second scenario is using radio boxes and not checkboxes, as you inferred.

Thanks again.