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 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jun 2011
    Posts
    148
    Thanks
    18
    Thanked 0 Times in 0 Posts

    dynamic FORM fieldname validation!!

    Hi Guys,

    is there a way to ask if the #FORM.fieldname# exist to proceed with the next one ?

    FYI : StartDateName22 is a dynamic generated textbox

    i am using the following code :

    <cfif not isDefined (#FORM.StartDateName22#) or #FORM.StartDateName22# or EQ "" >
    <cfoutput>
    Elemnt 2,2 is not defined
    </cfoutput>
    <cfelse>
    <cfoutput>
    Element 2,2 is defined asc: #FORM.StartDateName22#
    </cfoutput>
    </cfif>

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,079
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    Thi appears to relate to Coldfusion, not Javascript.

    Using Javascript you can check if a field exists:-


    Code:
    <input type="hidden" id = "test99" value="test99" >
    
    <script type = "text/javascript">
    function checkFieldExists() {
    var fld = document.getElementById("test99");
    if (fld == null)     {
    alert ("Field test99 does not exist");
    }
    else {
    alert ("Field test99 has the value " + fld.value );
    }
    }
    </script>

    The secret of success in life is honesty and fair dealing. If you can fake that, you've got it made. - Groucho Marx (1890 - 1977)

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #3
    Regular Coder
    Join Date
    Jun 2011
    Posts
    148
    Thanks
    18
    Thanked 0 Times in 0 Posts
    Sorry ,

    i really appologies

    beacuse iam using CF with Javascript i am completely confused with the right forms ,,
    thanks , i will put it in the CF forums as i need specifically to use CF isDefined syntax

    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
    •