Solved

coldfusion and Javascript

Posted on 2004-08-05
4
241 Views
Last Modified: 2013-12-24
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.
0
Comment
Question by:Isaac
  • 2
4 Comments
 
LVL 21

Expert Comment

by:pinaldave
ID: 11728790
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
0
 
LVL 15

Accepted Solution

by:
tim_cs earned 350 total points
ID: 11728892
One thing, you will need to have quotes around the date.  

<cfoutput>'#todaysDate#'</cfoutput>)
0
 
LVL 15

Expert Comment

by:tim_cs
ID: 11729125
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?
0
 
LVL 7

Expert Comment

by:suramsureshbabu
ID: 11729614
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 :)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Running Guacamole on port 80 5 105
Forbidden errors 5 107
Intranet building Software 8 71
CFFILE upload help 98 112
When setting up new project requests for our site, one of the most powerful tools our team has available to use is Axure (http://www.axure.com/). It’s a tool for creating software and web prototypes that can function and interact as if it were the a…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
The purpose of this video is to demonstrate how to Import and export files in WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Click on Too…
The purpose of this video is to demonstrate how to integrate Mailchimp with WordPress, by placing a Mailchimp signup form on a WordPress Page or Post. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mailchi…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now