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
    New Coder
    Join Date
    Jan 2012
    Posts
    14
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Smile Hide Submit on Date Select in Past

    Hey guys I need some assistance in developing a code that will hide the submit button of a form if a date in the past is selected. The variable for the date box is firstleveldate and the date appears in a MM-DD-YYYY format.

    Thanks!

  • #2
    Regular Coder
    Join Date
    Apr 2012
    Location
    St. Louis, MO
    Posts
    985
    Thanks
    7
    Thanked 101 Times in 101 Posts
    Load the form with the submit button disabled, then place an onBlur event in the firstleveldate field that checks the date value. If it's before the current date, do nothing; if it's AFTER the current date (or is the current date?), then document.forms["formName"].submitButtonName.disabled = false;
    ^_^

    If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
    *
    The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".

  • #3
    Regular Coder Lerura's Avatar
    Join Date
    Aug 2005
    Location
    Denmark
    Posts
    947
    Thanks
    0
    Thanked 130 Times in 129 Posts
    you can use this:
    Code:
    function TestDate(Input, CurDateValid){
    var seg=Input.split('-');
    var Dato=new Date(seg[2],seg[0]-1,seg[1]);
    var Now=new Date();
    var NowReset=new Date(Now.getFullYear(),Now.getMonth(),Now.getDate());
    return ((CurDateValid?NowReset:Now)<=Dato);
    }
    to test if the date is valid.

    If today is a valid date then
    Code:
    if (TestDate(firstleveldate,1)){
    --show/enable button--
    }else{
    --hide/disable button--
    }
    if not:
    Code:
    if (TestDate(firstleveldate,0)){  // or:  if (TestDate(firstleveldate)){
    --show/enable button--
    }else{
    --hide/disable button--
    }
    Last edited by Lerura; 06-24-2012 at 12:01 AM.


  •  

    Tags for this Thread

    Posting Permissions

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