Solved

CFINPUT TYPE=DATEFIELD Question

Posted on 2010-09-13
13
792 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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
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 500 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

10 Questions to Ask when Buying Backup Software

Choosing the right backup solution for your organization can be a daunting task. To make the selection process easier, ask solution providers these 10 key questions.

Question has a verified solution.

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

Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

623 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