date validation scrip

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Abby Lee

    #1

    date validation scrip



    I found the above date format script while doing a search.
    it works fine except with the format mm/dd/yyyy.
    Type in 01/02/03 and hit the "format date" link...the month and day
    will switch back and forth. This does not happen if you use the
    dd/mm/yyyy format. I want to use the mm/dd/yyyy part of this...can
    someone tell me where the problem is?
  • Dr John Stockton

    #2
    Re: date validation scrip

    JRS: In article <80504bef.04090 11140.193c23f5@ posting.google. com>,
    dated Wed, 1 Sep 2004 12:40:27, seen in news:comp.lang. javascript, Abby
    Lee <abbylee26@hotm ail.com> posted :[color=blue]
    >http://www.apriori-it.co.uk/FormatDate.asp
    >
    >I found the above date format script while doing a search.
    >it works fine except with the format mm/dd/yyyy.
    >Type in 01/02/03 and hit the "format date" link...the month and day
    >will switch back and forth. This does not happen if you use the
    >dd/mm/yyyy format. I want to use the mm/dd/yyyy part of this...can
    >someone tell me where the problem is?[/color]


    Having an off-line news reader, I rarely follow Web references while
    answering incomplete News questions. Your "switch back and forth" is
    most unclear.

    Date format mm/dd/yyyy is really stupid; 99% of countries, and parts of
    Canada, laugh sneer or weep at seeing it. You should follow the
    International standard, ISO 8601, which is AIUI also a US Federal
    standard; yyyy-mm-dd is correct and unambiguous; and yyyy-mm-dd is
    reliable.

    Evidence suggests that even Americans can understand a yyyy/mm/dd date
    when they see it.

    Read the newsgroup FAQ; see below.

    --
    © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
    <URL:http://www.jibbering.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
    <URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
    <URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.

    Comment

    • Dr John Stockton

      #3
      Re: date validation scrip

      JRS: In article <80504bef.04090 11140.193c23f5@ posting.google. com>,
      dated Wed, 1 Sep 2004 12:40:27, seen in news:comp.lang. javascript, Abby
      Lee <abbylee26@hotm ail.com> posted :[color=blue]
      >http://www.apriori-it.co.uk/FormatDate.asp
      >
      >I found the above date format script while doing a search.
      >it works fine except with the format mm/dd/yyyy.
      >Type in 01/02/03 and hit the "format date" link...the month and day
      >will switch back and forth. This does not happen if you use the
      >dd/mm/yyyy format. I want to use the mm/dd/yyyy part of this...can
      >someone tell me where the problem is?[/color]


      I've looked at the script. It is of low quality, and the HTML is not
      good either. The author clearly knows little of the subject, or is paid
      by the yard. If you want bloatware that gives US formats, properly
      tested, there are other sources.

      It accepts days & months with many leading zeroes, and keeps them. It
      does not extend years to 4 digits. Year 33 becomes 2033, but year 033
      remains. Year 0000 is not Leap.

      Each month can have the appropriate number of days 1..n , or 365/366 +
      1..n, or 730/731 + 1..n (roughly stated).

      It windows 2-digit years, but not 1-digit ones, into 1941..2040. It
      accepts "Janitor" and "Octopus" as month-names.

      It does toggle as described; while it can output UK & US forms, it reads
      as UK if possible. Of course, most of us expect the reverse fault <G>.

      To generate mm/dd/yyyy efficiently from a date object, if you must, see
      below and adapt, say,

      function LZ(x) { return (x<0||x>=10?"": "0") + x }

      Date.prototype. ISOlocaldateStr =
      new Function(" /* Date.ISOlocalda teStr */ with (this)\n return " +
      "getFullYear()+ '-'+LZ(getMonth() +1)+'-'+LZ(getDate()) ")


      If you have a numeric date string in another format, rearrange it with a
      RegExp .replace .

      --
      © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
      <URL:http://www.jibbering.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
      <URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
      <URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.

      Comment

      Working...