Date field (not not mandatory) causing an error... Please help!

Hello, I'm a beginner when it comes to ColdFusion could someone please help with this question?

I have a field date in my application which is not necessary, I want that the users have the choice to leave this field blank.

Here's a breakdown of what I have in progress:

On the add/edit page:

< component cfinvoke = 'test '.

method = 'get '.

ReferenceNumber = '#URL. "RefIDNum #

returnvariable = "record" >

< cfset ThisIsTheDateField = DateFormat (record. ThisIsTheDateField, ' MM/DD/YYYY') >

< cfform action = "process.cfm" >

< cfinput type = "Text".

name = "ThisIsTheDateField".

value = "" #ThisIsTheDateField # ""

message = "ThisIsTheDateField must be a valid date."

required = "no".

validate = 'date '.

validateAt = 'onSubmit '.

size = "50".

MaxLength = "10" >

On process.cfm:

< name cfinvokeargument = "ThisIsTheDateField."

value = "#DateFormat (FORM." ThisIsTheDateField) #">"

On the SWC's Page:

<!--> method arguments

< cfargument = "ThisIsTheDateField" name

Type = "date".

required = "no".

Hint = 'Field ThisIsTheDateField' >

The value for this field of application:

#CreateODBCDate (ARGUMENTS. ThisIsTheDateField) #.

The error I get is:

Error occurred while processing request

The THISISTHEDATEFIELD argument passed to the add function is not of type date.

If the component name is specified as a type of this argument, it is possible that a file of the component definition is not found or is not accessible.

The error occurred in E:/site/test.cfc: line 56

54:

55: <! - add a record - >

56: < cffunction = name 'Add '.

57: returntype = "boolean".

58: index = 'add record' >

I need a way to make this field accepts empty input... when I leave the field blank, I get the error above.

Thank you!


ear,

If you want to use an optional argument in your function, you must be able to check whether or not a value for the argument had passed.  Use IsDefined ("arguments. ThisIsTheDataField') for its determination:

Looks like you can also consult the documentation on Coldfusion functions here (http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-7ff3.html).

Tags: ColdFusion

Similar Questions

Maybe you are looking for