Solved

coldfusion and Javascript

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
Now that Expression Web 4.0 (http://www.microsoft.com/expression/products/Upgrade.aspx) is free if you buy or have the full version of Expression Web 3.0, now is the best time to  migrate from FrontPage to Expression Web (http://www.frontpage-to-exp…
The purpose of this video is to demonstrate how to automatically show related posts at the bottom of a blog post in WordPress. This will be demonstrated using a Windows 8 PC. Plugin “Yet Another Related Posts Plugin” will be used. Go to your…
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…

867 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

12 Experts available now in Live!

Get 1:1 Help Now