Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

date format

Status
Not open for further replies.

bluestarcpc

Technical User
May 2, 2005
2
US
I have a field on a form called payweek_start
It is not a flash form.
payweek_start is defined as type=text
<CFInput name="payweek_start" type = "text">
payweek_start displays as 2005-01-24 00:00:00
I need to do 2 things
I would like to display payweek_start as 02/24/2005
and
I would like the day1.value to show as 24

day1.value = PayItemList[SelIndex+1].payweek_start

since I am not using flash, I cannot use dateformat or mask
what is the best way to parse out a date string
 
Since you're using <cfinput> you can use one of its own attributes.


<cfinput type = "Text" name = "payweek_start" message = "Please enter a correctly formatted date (dd/mm/yy)" validate = "date" required = "No">



What is day1?? Is that another field?? Or just formating the "payweek_start" field into day1??

On a side note, I would not use the <cfinput> or even <cfform>, they are heavily depended on Java. If your user does not have the current version of java installed the results will not be the same. Instead use the <form> and <input> and use JS to format the "payweek_start" field.


____________________________________
Just Imagine.
 
bluestarcpc,

If I understand you correctly, you are trying to format a date as the user types it in? If thats the case, then you probably want to post your question in the javascript forum. If that is not the case and you want to know how to convert the user's inputed value into another date format, then you would want to use dateFormat() function with the mask "mm/dd/yyyy".ie:
Code:
<!--- initialize your incoming form field --->
<cfparam name="form.payweek_start" type="string" default="#now()#">

<!-- check to see that it is a valid date, if so then change the format of the date --->
<cfif isDate(form.payweek_start)>
   <cfoutput>#dateFormat(form.payweek_start,"mm/dd/yyyy")#</cfoutput>
</cfif>

To add to GUJUm0deL comments on <cfform> ...

CF has improved the functionality and display of the <cfform> tag in MX7. The client no longer has to install any plugins or 'download' any applets to view <cfinput type="text" ..> form fields. The only thing is, is that the user must have javascript enabled in their browser in order for the form to work properly, even if format = "flash".

Here is the documentation for MX7's <cfform>:

I hope this helps,

jalpino
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top