Solved

coldfusion and Javascript

Posted on 2004-08-05
4
248 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Text Transformation using ActionScript 3 5 152
use of cookies and regulations 1 100
Question to locate the problem 18 127
Ways to assess https/ssl websites 3 103
This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
This article provides a case study on how our local youth baseball league deployed a new website, including the platform selection, implementation and benefits to the league.
The purpose of this video is to demonstrate how to Test the speed of a WordPress Website. Site Speed is an important metric of a site’s health. Slow site speed can result in viewers leaving your site quickly and not seeing your content. This…
The purpose of this video is to demonstrate how to prevent comment spam on a WordPress Website. This will be demonstrated using a Windows 8 PC. Plugin Akismet will be used. Go to your WordPress login page. This will look like the following: myw…

837 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