ColdFusion Language





ColdFusion is a server-side rapid application development platform originally created by Allaire and now sold by Adobe, implementing the dynamic general purpose CFML programming language. The term ColdFusion is sometimes colloquially used to refer to the CFML language (Cold Fusion Markup Language), but can also include discussions of the server software implementation. ColdFusion runs using a customised version of Apache Tomcat. Earlier versions are bundled with JRun.

Share tech news, updates, or what's on your mind.

Sign up to Post

Form field validation for a date requirement to be: Current date on or after 10/01/2017 - cold fusion form

A new requirement for a form. I need to detect the date a form is being submitted to be the current date on or after 10/01/2017 in a cold fusion form.

The date won't be placed into the form field/s but I need to detect the date. This will be implemented on 10/01/2017 fyi. I'll need to set the code up to test say for today's date then once working set it up to detect 10/01/2017 for when it goes live.

Thanks for any help. I'll start researching the topic as I've never tried to work this type of code before. Current code for one of the fields is:

  <cfset errorMsg = ""> 
   	<cfif NOT refind("^[DdFfGgHhNnVv][A-Za-z0-9]{1,21}$", form.Contract_Number) AND NOT refind("^70[Zz]0[a-zA-Z0-9]{2}\d{2}[a-zA-Z][a-zA-Z0-9]{8}$", form.Contract_Number)>
	   <cfset errorMsg = "The Contract Number is required and can contain no more than 22 alphanumeric characters.,">
	<cfset session.invoiceDataContr.errorString = errorMsg>

Open in new window

Congratulations! You’re Certified – Now What?
Congratulations! You’re Certified – Now What?

Starting a new career can be overwhelming. Becoming certified in your field of expertise is a great start, but where do you go from here?  Here are some tips to help you on your career journey.

Hi, I have a dynamic CF page with  printout tables. Problem is with printing. Table printout can be split depending on the dynamic content. I need to force a new page for each table output. Is there a CF or html string I can use to force this break

many thanks
Hello Experts,

I am working on a CF application and need a CF function equivalent to exit(); (PHP).

I am trying to addess this particular fix
Acunetix reference

This is what I am doing, but not sure if t works.  

<cfset GetPageContext().getCFOutput().clear()>
   <CFLOCATION URL="Login.cfm?Message=Logon ID must be 5 digits." ADDTOKEN="no">

Open in new window

- Dan
I have courses for agents to study online.  I have a save and exit button when clicked will save their place and close the window.  However, if the student just clicks on the X on their browser and closes the window my system does not currently recognize that they are no longer active in the course.  We tried "onbeforeunload" but that gets triggered if the student is just going to the next page.  I only want to trigger it if they click to close the browser using the X.
I have a form that is completed online that now needs to be generated as a saved pdf file in a folder on the server. The name and location for the pdf would then be emailed to someone for them to retrieve for viewing. As an aside, would also need to know best way to have a signature placed into the pdf when created (I realize this is 2 questions in 1. 1st one more important for now)
I have the code below trying to use cfif and cfelseif to validate on form field, which is for a contract number. I need to use one form field but validate w/ 3 different sets of criteria using 3 different sets of regex validations. Its currently not working and I'm sure the syntax I'm using is off. I'm new to CF much less using cfelseif but I believe I'm on the right track...can anyone provide some suggestions on how to rework this please?

thanks in advance...see code below:
    <cfparam name="form.Contract_Number" pattern="^[DdFfGgHhNnVv][A-Za-z0-9]{1,21}$" type="regex" default="#form.Contract_Number#">
		<cfset #session.invoiceDataContr.errorString# = #session.invoiceDataContr.errorString#&"The USCG Contract Number is required and can contain no more than 22 alphanumeric characters,">
       <cfparam name="form.Contract_Number_Z" pattern="^70Z0\d{4}[CDF]\d{8}$" type="regex" default="#form.Contract_Number_Z#">
		<cfset #session.invoiceDataContr.errorString# = #session.invoiceDataContr.errorString#&"The TSA Contract Number is required and can contain no more than 22 alphanumeric characters,">
        <cfparam name="form.Contract_Number_T" pattern="^70T0\d{4}[CDF]\d{8}$" type="regex" default="#form.Contract_Number_T#">
		<cfset #session.invoiceDataContr.errorString# = 

Open in new window

Good Afternoon, I would like to get some assistance with something I'm trying to do. I have a query that queries a table and gets various project information from that table, and it works fine. I have another table that has many comments about each project, so I have a one to many situation. My problem is that all UI want to retrieve from that second table is the last comment entered. I store the date of the last comment so I thought I would be able to do some sort of retrieval with a max date but not sure how to go about it. Ultimately I'm building a spreadsheet so the query is being built to populate the spreadsheet. Everything works fine till I had the 'proj_reason_closed' field. That the field that has many entries for each project.




      FROM   mca.current_bulk_filter

left join mca.spend_plan_history
        ON ( current_bulk_filter.proj_no = spend_plan_history.proj_no and

WHERE ......
is it possible to set up a regex to validate each position in a string of characters in a form field?

I have a requirement for a contract number field in a Cold Fusion form. Requirements are:

•      Positions 1-6 will be the  70Z0XX where XX is the contracting office code IE: 23.
•      Positions 7-8 will be the two digit Fiscal Year IE: 17.
•      Position 9 will be the one character instrument code IE: C, D, F.
•      Positions 10-17 will be agency assigned number.
•      New Example: 70Z02317D00000001

Is it possible to set up an expression at different points w/in the string of characters? I've never done that...only length requirements and forcing it to start w/ either a number or a letter. thanks for any help.
I want to keep cookies alive even after restarting Coldfusion on the server each morning.  Screen-Shot-2017-06-21-at-8.51.25-AM.pngI am attaching the settings from Coldfusion.

Thanks for your help
I have one form field with a Cold Fusion form that is requiring 2 different sets of criteria for validation....can this be done?

I have 2 sets of criteria for a contract number field w/in a CF form field. One is requiring the contract number to begin with a numeric character the other alphanumeric. I currently have the one set that needs to start w/ a letter but need to add the validation using a regex to the same form field to trigger the field to validate for the additional set of criteria that requires the new contract number configuration to begin with a number.

Current setup for the validation is:

			, Contract_Number: {
				required: true
			   ,pattern: /^[DdFfGgHhNnVv][A-Za-z0-9]{1,21}$/

Open in new window

Form field setup:

                        	<font face="Arial" size="2" color="#990000">
                            <label for="Contract_Number">Contract Number:&nbsp;</label>
							 <input type="text" name="Contract_Number" id="Contract_Number" minlength="8"  maxlength="22" tabindex="7" value="<cfif structkeyexists(session.invoiceDataContr, "PASS")><cfoutput>#session.invoiceDataContr.Contract_Number#</cfoutput><cfelse><cfoutput>#form.Contract_Number#</cfoutput></cfif>" required/>
                        	<font size="1" color="navy" title="No hyphens or special characters, OF-347 block 2, SF-26 block 2, SF-1442 block 4, SF-1449 block 2, SF-33 block 2">(help)</font></font>

Open in new window

Is there a way to use a hidden field maybe? I'm not sure its even possible to do. This will need to use jquery for client but also needs server side validation as well.

I'm thinking I can use as try catch and w/in that use a cfif/cfelse setup:

Open in new window

Learn by Doing. Anytime. Anywhere.
Learn by Doing. Anytime. Anywhere.

Do you like to learn by doing?
Our labs and exercises give you the chance to do just that: Learn by performing actions on real environments.

Hands-on, scenario-based labs give you experience on real environments provided by us so you don't have to worry about breaking anything.

Bootstrap validator trying to validate the form and submit to the database. The validation part works but it does not submit

the link is here
I am trying to validate using remote options, but it is always validate as failed
<div class="row">
										<div class="col-sm-12 col-xs-12">
											<input type="text" name="userName" placeholder="Username" class="form-control input-lg" required="required" data-bv-remote="true"/>

Open in new window

 userName: {
                message: 'The username is not valid',
                validators: {
                    notEmpty: {
                        message: 'The username is required and can\'t be empty'
                    stringLength: {
                        min: 6,
                        max: 30,
                        message: 'The username must be more than 6 and less than 30 characters long'
                    regexp: {
                        regexp: /^[a-zA-Z0-9_\.]+$/,
                        message: 'The username can only consist of alphabetical, number, dot and underscore'

                    remote: {
	                    url: '/includes/website.cfc?method=checkusername',
	                    message: {
	                        en_US:  "This usenrame is already taken, please choose another one",
	                    data: {
	                        type: 'userName'
	                    type: 'POST',
	                    delay: 1000


Open in new window

<cffunction name="checkusername" output="true" returntype="any" access="remote" returnformat="JSON" >
          <cfargument name="username" required="true" type="string" />
          <!--- set the default value to false --->
          <cfset var emails = StructNew() />
          <cfset emails.valid = "false" />

          <!--- code to check email in system --->
          <cfquery name="findemail" datasource="#request.datasource#">
               select username
               from users
               where username = <cfqueryparam  value="#arguments.username#" cfsqltype="cf_sql_varchar" />
          <cfif findemail.RecordCount eq 0>
               <cfset emails.valid = "true" />

Open in new window

I am looking for a solution that uses CFSCRIPT to remove all text that is surrounded by '<style' and '/style>' including removing the style tags. Can someone show me how I can use something like ReReplaceNoCase to solve this.

For example: if I have text that looks like:

section a <style>here is style to remove</style>section b <style>more style to remove</style>section c

I need the function to return:
section a section b section c

Thank you.
I have an invoice form that needs a date field to be formatted with mm/dd/yy . Its currently working on the client side fine but on the server side I have issues with javascript turned off which is the whole reason I'm formatting it this way. The security requirement is for server  side to catch issues if someone is trying to hack the form w/ javascript turned off in firefox.

Here's the code I have for the parameters:
<cfparam name="form.Invoice_Date" default="">

<cfif session.invoiceDataContr.fileError NEQ 2>
<cfset session.invoiceDataContr.Invoice_Date = "#form.Invoice_Date#">
<cfparam name="form.Invoice_Date" default="">

<cfset session.invoiceDataContr.Invoice_Date = "#session.invoiceDataContr.Invoice_Date#">

Open in new window

form field:
	<cfset myDate = "#form.Invoice_Date#">
<cfset myYear = #DatePart("yyyy", todayDate)#>
	<cfif isValid("usdate", form.Invoice_Date)>
	     <cfset r_myDate = "20#right(form.Invoice_Date, len(form.Invoice_Date)- 6)#">	
		 <cfif r_myDate GT myYear> 
			<cfset #session.invoiceDataContr.errorString# =#session.invoiceDataContr.errorString#&" No future dates are allowed. Enter date in MM/DD/YY format.,">
			<cfif datecompare(todayDate, myDate, "d") EQ -1> 
				<cfset #session.invoiceDataContr.errorString# =#session.invoiceDataContr.errorString#&" No future dates are allowed. Enter date in MM/DD/YY format.,">
		<cfset #session.invoiceDataContr.errorString# =#session.invoiceDataContr.errorString#&" The Invoice Date is required. No future dates are allowed. Enter date in MM/DD/YY format.,">

Open in new window

hidden field:
<input type="hidden" name="Invoice_Date" id="Invoice_Date" value="#HTMLEditFormat(session.invoiceDataContr.Invoice_Date)#">

Open in new window

Its giving me an internal server error when I put the date in as: 4/2/17.

The cf application error log is returning:

The 2 parameter of the Right function, which is now 0, must be a positive integer The specific sequence of files included or processed is: D:\inetpub\wwwroot\**********\**********_verify.cfm, line: 127

It's working for most everything else but this isn't being caught. Before its suggested to use mm/dd/yyyy I can't do that. Specific requirement which is really screwing things up or this wouldn't be an issue likely.

Thanks for any suggestions.
Can I use ReReplaceNoCase or someother javascript function to  remove everything in a string from and including '<style' to '/style>'? What would the function call look like?
I have created a bootstrap popup login page . When the client click on the login button it will launch the popup and the client will be asked to either login or register. Once login button is clicked I need to validate the credentials and log them in. If the login is not successful I Need to keep them on the same page and show the error message.

Also   I have 2 options forgot user name and forgot password I need to incorporate that within the same popup so it slides and another form is shown
<li class="login-link"><a href="#" data-toggle="modal" data-target="#myModal">Login</a></li>

<div id="myModal" class="modal fade" role="dialog">
			<div class="modal-dialog">
			    <!-- Modal content-->
			    <div class="modal-content">
			    	<div class="modal-header">
			        	<button type="button" class="close" data-dismiss="modal">&times;</button>
						<h2 class="modal-title">Account Login</h2>
					<div class="modal-body">
						 <form data-toggle="validator" role="form">
			        	<h3>Welcome to I Drive Smart. Please log-in to access your account.</h3>
			        	<div class="form-group">
			        		<input class="modal-username" type="text" name="firstname" class="form-control" data-error="Please enter name field." placeholder="Username" required="required">
			        			<div class="help-block with-errors"></div>
			        	<div class="form-group">
			        		<input class="modal-password" type="password" 

Open in new window

The following code fails and shows the error output in the title. What the heck is going on? Thanks for considering this.

               <form method="post" enctype="multipart/form-data">
                        Select a file:
                        <input type="file" name="fileUpload">
                        <input type="submit" value="Upload File">
                  <cffile action="upload"
                  accept = "application/pdf,application/msword"

                          <cfdump var="#FileUploadedYes#">
I waste lots of time trying to figure out why an insert or update query in ColdFusion is not working.

I typically write code that loads a database table from some other database table.  

It works fine for the first few records, but then I get an error.

I'm loading maybe 15 to 20 columns of data for each record.

What I have been doing is eliminating one column at a time, until I find the piece of data that was not fitting.

Is there a faster way to do this?  

Should I put the query into SQL Server Mgt Studio?  But then I have to copy and paste each bit of data I want to store?

I just can't afford to be this inefficient.  

Hope you can help
I have a coldfusion query and I need to search the query by the address with the proximity of 5 miles. The client type their home address and I need to show desired location in the radius of 5 miles
What is a Denial of Service (DoS)?
What is a Denial of Service (DoS)?

A DoS is a malicious attempt to prevent the normal operation of a computer system. You may frequently see the terms 'DDoS' (Distributed Denial of Service) and 'DoS' used interchangeably, but there are some subtle differences.

I have a coldfusion application running with msql Server 5.7 and windows 7.  While the application works correctly, I am unable to backup the database office_18.sql. The error message is shown below.

I have the same application working on two other pcs which run Windows 10. The backup work in these instances

Is there a known window7  problem in this area and if so, a workaround ?

thanks for any help


windows 7
Mysql Server 5.7
Application works

   <!--- Increase timeout to account for db size. Larger db's require more time for backup --->
   <cfexecute name='C:\Program Files\MySQL\MySQL Server 5.7\bin\mysqldump.exe'
      arguments=" -uroot -pBuddyholly_69 office_18"
      timeout="120" />  
      <!---errorMessage = <cfoutput>#errorMessage#</cfoutput><br>--->
      <cfdump var="#GetFileInfo('C:\mysql_backups\office_18.sql')#">
      <strong>Votre sauvegarde 1 a reussi</strong> C:\mysql_backups 
<cfcatch type="any">  
         <span class="style1"><strong>Votre sauvegarde 1 a echoue</strong></span> C:\mysql_backups  
<cfdump var="#cfcatch#">  

Open in new window

error message
Cannot run program "C:\Program Files\MySQL\MySQL Server 5.7\bin\mysqldump.exe": CreateProcess error=2, Le fichier spécifié est introuvable
Hello, I have some ColdFusion code that runs when the user presses a button. I am using: <cfif structKeyExists(form, "btnRuleCode")> .....code here....</cfif>

My problem is, I need to add a confirmation that pops up when they click the button, so that the user will see a confirmation that pops up before allowing this code to run, or cancel it. I know how to do this with javascript, but I don't know how to stop it from creating that stuctKey when they press the button. Does this make sense? Can anyone assist?

Thank you.
I have a form w/ several of the fields requirements states: The Contract Number is required and can contain no more than 22 alphanumeric characters. This can't contain spaces however:

here's the current regex setup:

	, Contract_Number: {
				required: true
			   ,pattern: /^[DdFfGgHhNnVv][A-Za-z0-9]*$/

Open in new window

Does anyone have any suggestions on how to modify this?
Hi all,

First off thanks for taking the time to look at my concern. Second, I'm a relative newbie to CF, so if it seems like I'm asking the wrong questions, I probably am...

If I cfset application.PropertyName = Property, and then cfdump the application scope, that property appears as expected with the correct value. For example:
<cfif isDefined(form.campaign) AND len(form.campaign) >
        <cfset application.campaign = form.campaign />
        <cfset application.campaign = 'default' />
<cfif isDefined( AND len(>
        <cfset = />
        <cfset =>
<cfdump var="#application#" />
<cfabort />

Open in new window

renders the form.campaign and properties properly as application properties.

However, if I cflocation="/path"  to another view after doing so, and cfdump="#application#" again, those properties are no longer available.

This *seems* to be a weirdness regarding Mura, but I'd happily be corrected.

While trying to find out anything I can about this, I stumbled upon the Mura docs for their own scope object, the Mura scope. Is this intended to take the place of Application scope within the context of their framework?

Many thanks.
what is wrong with this ?
<CFQUERY datasource="#Application.dsn#" name="addProduct">
                INSERT INTO productsHistory
                 ( <cfqueryparam value="#code#" cfsqltype="cf_sql_varchar" maxlength="25">,
                    <cfqueryparam value="#commercialname#" cfsqltype="cf_sql_varchar" maxlength="255">,
                    <cfqueryparam value="#web#" cfsqltype="cf_sql_varchar" maxlength="5">,
                    <cfqueryparam value="#category1#" cfsqltype="cf_sql_varchar" maxlength="100">,
                    <cfqueryparam value="#description#" cfsqltype="cf_sql_longvarchar">,
                    <cfqueryparam value="#topnote#" cfsqltype="cf_sql_varchar" maxlength="50">,
                    <cfqueryparam value="#middlenote#" cfsqltype="cf_sql_varchar" maxlength="50">,
                    <cfqueryparam value="#bottomnote#" cfsqltype="cf_sql_varchar" maxlength="50">,
                    <cfqueryparam value="#fp#" cfsqltype="cf_sql_varchar" maxlength="25">,
                    <cfqueryparam value="#dep#" cfsqltype="cf_sql_varchar"

I need your help please,

This is what I currently have 
<cfset SpreadsheetAddRow(sObj,"GROUP PRPR ID,GROUP NAME")>

Open in new window


This is what I want 
<cfset SpreadsheetAddRow(sObj,"GROUP PRPR ID" & <cfif isdefined('form.GroupName')> ",GROUP NAME" </cfif>")>

I want to be able to say if the Group Name is available then display it. 

Open in new window

Thank you for your help

ColdFusion Language





ColdFusion is a server-side rapid application development platform originally created by Allaire and now sold by Adobe, implementing the dynamic general purpose CFML programming language. The term ColdFusion is sometimes colloquially used to refer to the CFML language (Cold Fusion Markup Language), but can also include discussions of the server software implementation. ColdFusion runs using a customised version of Apache Tomcat. Earlier versions are bundled with JRun.