Copy link to clipboard
Copied
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!
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>
Copy link to clipboard
Copied
<cfinput type="text" name="myDate" id="myDate" required="yes" mask="#localeDateMask#" message="Enter a valid date in the format #localeDateMask#" validateat="onsubmit,onserver" />
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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>
Copy link to clipboard
Copied
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.