Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Oct 2002
    Location
    Oakland, CA
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Detect whether form field is HIDDEN or not

    Hi,

    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,
    hyefive

  • #2
    Super Moderator sage45's Avatar
    Join Date
    May 2002
    Posts
    1,059
    Thanks
    0
    Thanked 13 Times in 13 Posts
    Perhaps a link for us to look at or your code...

    -sage-
    HTML & CSS Forum Moderator

    "If you don't know what you think you know, then what do you know."
    R.I.P. Derrick Thomas #58
    1/1/1967 - 2/8/2000

  • #3
    New Coder
    Join Date
    Oct 2002
    Location
    Oakland, CA
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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,
    Mark

  • #4
    New Coder
    Join Date
    Oct 2002
    Location
    Oakland, CA
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts
    No, I take it back. That didn't work after all...

  • #5
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,037
    Thanks
    0
    Thanked 250 Times in 246 Posts
    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.

  • #6
    New Coder
    Join Date
    Oct 2002
    Location
    Oakland, CA
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •