Solved

coldfusion and Javascript

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
Objective of This Article In 1990’s, when I was a budding software professional, I had a lot of confusion about which stream or technology, I had to choose to build my career. In those days, I had lot of confusion like whether to choose System so…
The purpose of this video is to demonstrate how to manually back up a WordPress Database. This will be demonstrated using a Windows 8 PC. The Host used will be IPage.com Log into your Hosting account. IPage will be used for demonstration : Locat…
The purpose of this video is to demonstrate how to reset a WordPress password if you are locked out and cannot reset the password. A typical use would be if you cannot access the email to which WordPress would send the password recovery email to…

776 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