Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Date masking by cflocale

New Here ,
Jun 23, 2009 Jun 23, 2009

I'm trying to create a form in my localised web application which will use the cflocale value to mask a text based date-input field.

I don't want to use a calendar tool as the date selection method, but would like to be able to use something along the following lines:


<cfinput type="text" name="myDate" id="myDate" required="yes" mask="#localeDateMask#" message="Enter a valid date in the format #localeDateMask" validateat="onsubmit,onserver" />

Ideally, I was wondering if I can populate the localeDateMask variable from the underlying java locale setting. Otherwise, I'm going to have to create a look-up table to get this value for each possible locale. No problem doing that, but I'd rather not re-invent the wheel!

1.7K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Enthusiast , Jun 23, 2009 Jun 23, 2009

guess it got truncated via email gateway. lets see if the web forum works better.

<cfscript>
formatStyle=0; // full 0--->3 short
thaiLocale=createObject("java","java.util.Locale").init("th","TH");
dF=createObject("java","java.text.DateFormat").getDateInstance(formatStyle,thaiLocale);
writeoutput("#dF.toPattern()# <br>for example: #df.Format(now())#");
</cfscript>

Translate
New Here ,
Jun 23, 2009 Jun 23, 2009

<cfinput type="text" name="myDate" id="myDate" required="yes" mask="#localeDateMask#" message="Enter a valid date in the format #localeDateMask#" validateat="onsubmit,onserver" />

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jun 23, 2009 Jun 23, 2009

you mean something like this?

<cfscript> formatStyle=0; // full 0--->3 short thaiLocale=createObject("java","java.util.Locale").init("th","TH"); dF=createObject("java","java.text.DateFormat").getDateInstance(formatStyle,thaiLocale); writeoutput("#dF.toPattern()# <br>for example: #df.Format(now())#");

</cfscript

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 23, 2009 Jun 23, 2009

Thanks for your prompt answer, Paul.

I'm not sure if your example was truncated or I'm being stupid.

Where is the df variable populated in your example?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jun 23, 2009 Jun 23, 2009

guess it got truncated via email gateway. lets see if the web forum works better.

<cfscript>
formatStyle=0; // full 0--->3 short
thaiLocale=createObject("java","java.util.Locale").init("th","TH");
dF=createObject("java","java.text.DateFormat").getDateInstance(formatStyle,thaiLocale);
writeoutput("#dF.toPattern()# <br>for example: #df.Format(now())#");
</cfscript>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 23, 2009 Jun 23, 2009
LATEST

Thanks ever so much, Paul.

#dF.toPattern()# is exactly what I'm after in your example and I should be able to take things from there.

As ever, you are THE MAN when it comes localisation issues.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources