[whatwg] Suggested changes to Web Forms 2.0, 2004-07-01 working

George Lund george at lund.co.uk
Wed Jul 14 15:27:22 PDT 2004

In message <851c8d3104070906174ce4bfb0 at mail.gmail.com>, Jim Ley
<jim.ley at gmail.com> writes
>And because of regional
>differences in how dates are entered, it means it's not even safe to
>parse a date from a string, unless you know the format entered.

Help can be given to IE users that have scripting enabled, which
constitutes the majority of the 'problem' situations we are talking

For example, the following VBScript code will reformat the date the user
types into ISO format, taking into account the local standard format. So
if a US user types '1/10/1980', the input box will change to read
'1980-01-10' ... but if a UK user types that then the input box will
read '1980-10-01'.

Sub convertDate
    Dim the_date
    Dim user_locale

    If Not IsDate(myform.mydatetime.value) Then Exit Sub

    ' convert the date using the user's current locale
    the_date = CDate(myform.mydatetime.value)
    user_locale = GetLocale

    ' display the date using Sweden's locale
    myform.mydatetime.value = FormatDateTime(the_date, vbShortDate)

End Sub

(The locale 'sv-se' is indeed Sweden but fortunately Microsoft says
Sweden uses ISO date formatting.)

One could call this code from the form's "OnSubmit" event and/or from
the "OnFocusOut" event of the relevant input control.  All without
having any effect on a browser that doesn't understand VBScript.

Don't know if that contributes to the current debate, but it certainly
might make things more friendly for users of IE.  They could type the
date format in whatever way makes sense to them, and (assuming scripting
is enabled) the right thing will get sent to the server.

Needless to say it doesn't do away with the need for server-side
validation.  And I'm not claiming that my code above is pretty :-)

Reference: <URL:http://msdn.microsoft.com/library/en-us/script56/html/vs
George Lund

More information about the whatwg mailing list