Link to home
Start Free TrialLog in
Avatar of Isaac
IsaacFlag for United States of America

asked on

coldfusion and Javascript

I have a form with a field that pulls a date from the database and also a field that accepts a date.
I want to make sure that the date entered in the form is not less than what's being pulled from the database.

This is what I have so far but it's not working:

<CFSET todaysDate = #DateFormat(Now(), "DD MMM YYYY")#>

<SCRIPT type="text/javascript">
<!--
function fraud_onSubmit(theForm)
{
    var controlCounter;
    var returnValue = true;
    var formControl;
      
      if (theForm.closed_date.value <  <cfoutput>#todaysDate#</cfoutput>)
      {
            alert("hello");
            return false;
      }
      
    return returnValue;
}
// -->
</script>

Thank you for your help in advance.
Avatar of pinaldave
pinaldave
Flag of India image

Hi TheInnovator,
I am not sure about the answer but just wanted to make sure if following is producing correct output.
 #DateFormat(Now(), "DD MMM YYYY")#>
Try this  #DateFormat(Now(), "DD MM YYYY")#>

This not the answer but just found something in your code so I just dropped a note.

Regards,
---Pinal
ASKER CERTIFIED SOLUTION
Avatar of tim_cs
tim_cs
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
also, instead of doing DD MMM YYYY just do a single D with dashes.  "D-MMM-YYYY"

What error message are you getting if any?
Avatar of suramsureshbabu
suramsureshbabu

Try this script

<CFSET todaysDate = #DateFormat(Now(), "DD MMM YYYY")#>

<SCRIPT type="text/javascript">
<!--
function fraud_onSubmit(theForm)
{
    var controlCounter;
    var returnValue = true;
    var formControl;
var datenow = new Date(<cfoutput>#todaysDate#</cfoutput>);
var dateform = new Date(theForm.closed_date.value);
     
     if (dateform <  datenow)
     {
          alert("hello");
          return false;
     }
     
    return returnValue;
}
// -->
</script>

Suresh :)