Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

CFINPUT TYPE=DATEFIELD Question

Posted on 2010-09-13
13
Medium Priority
?
795 Views
Last Modified: 2013-12-24
Hi,
I am using the pop up date field provided by CF by using the Type="datefield" :

<cfinput name="toDate" type="datefield" class="inputboxShort"  required="no" size="40" maxlength="10"  readonly="readonly" />

I'd like to open the field up for input and provide only my own server side edit of the field BUT CF seems to have an implied option of validate="date" (makes sense I guess).  Is there a way to override that?  I'd  like to control the display of my own error message on the page.

Could I use a validate= regex that accepts anything or nothing?  What is that regex?

I think I'll need to keep it read only?

Thanks in advance,
hefterr
0
Comment
Question by:hefterr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
  • 2
13 Comments
 
LVL 52

Expert Comment

by:_agx_
ID: 33664268
>> seems to have an implied option of validate="date"

Are you sure? I did a quick test and didn't any problem entering a non-date like "ABC" in the box.

<cfform method="post">
      <cfinput name="toDate" type="datefield"
                  required="yes" size="40" maxlength="10" />
      <input type="submit">
</cfform>
0
 
LVL 19

Expert Comment

by:erikTsomik
ID: 33664366
I am not sure you need validation. Just make the field read only so the user can not update the date and in this case forget about validation
0
 
LVL 52

Expert Comment

by:_agx_
ID: 33664504
Yeah, I'd agree.  Though I'm not sure it even does validation in the first place ...
0
Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

 
LVL 1

Author Comment

by:hefterr
ID: 33664552
Hi agx,
I'm not sure what I'm doing differently - But I'm getting the error message page (see attached).

Maybe something on my server side code when I process the form.
Datefield.doc
0
 
LVL 1

Author Comment

by:hefterr
ID: 33664658
agx,
It as if I took you code and added a value statement :

<cfform method="post">
      <cfinput name="toDate" type="datefield"
                  required="no" size="40" maxlength="10"  value="mm/dd/yyyy" />
      <input type="submit">

You would get the same error.

hefterr
0
 
LVL 1

Author Comment

by:hefterr
ID: 33664735
OK guys, I found the problem.

I tried using in the CFFORM tag, Preservedata="yes".  This is causing the problem.  When I take it out it's OK.  I tried using it as a short cut to redisplay the data on an error - but it causes a problem in this case.

I guess it's back to the drawing board.  I'll have to repopulate manually the input date fields on an error.

Thanks,
hefterr
0
 
LVL 1

Author Comment

by:hefterr
ID: 33664888
folks,
.... and you cannot give an invalid "value = " to the CFINPUT statement.

That was my ORIGINAL question to begin with.  Soooooo, any suggestions?

hefterr
0
 
LVL 19

Expert Comment

by:erikTsomik
ID: 33664898
just make todays date as a default
0
 
LVL 52

Expert Comment

by:_agx_
ID: 33664940
Yeah, unfortunately preserveData has ... limitations. If you supply a "value" (or if preserveData  does), CF will validate that "value" on the server side.  So if you want to use preservedata you'll have to manually handle that field.  

Try deleting that key if it is NOT a date.

<cfparam name="form.toDate">
<cfform method="post" Preservedata="yes">
      <cfif NOT isDate(FORM.toDate)>
            <cfset structDelete(FORM, "toDate")>
      </cfif>
      <cfinput name="toDate" type="datefield"
                        required="yes" size="40" maxlength="10"
                         />
      <input type="submit">
</cfform>
0
 
LVL 52

Expert Comment

by:_agx_
ID: 33664948
Correction:

<cfparam name="form.toDate" default="">
<cfform method="post" Preservedata="yes">
      <cfif NOT isDate(FORM.toDate)>
            <cfset structDelete(FORM, "toDate")>
      </cfif>
      <cfinput name="toDate" type="datefield" size="40" maxlength="10" />
      <input type="submit">
</cfform>
0
 
LVL 52

Accepted Solution

by:
_agx_ earned 2000 total points
ID: 33665026
>> and you cannot give an invalid "value = " to the CFINPUT statement.

Yeah, I see the only way you can pass an invalid value to the CFINPUT is with javascript - ie after the fact. You can't do it using "value"

      <script>
            document.getElementById('toDate').value = 'blah blah. something invalid';
      </script>
0
 
LVL 1

Author Comment

by:hefterr
ID: 33665411
Hi agx,
One last question.  Where exactly would I put this Javascript statement if I removed Preservedata?

Thanks again for you expertise!!
hefterr
0
 
LVL 52

Expert Comment

by:_agx_
ID: 33665567
I'd put it in a function (for clarity) then call it onLoad

ie
<body onLoad="yourFunction()">

0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

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 …
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

722 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