Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Dec 2005
    Posts
    217
    Thanks
    1
    Thanked 0 Times in 0 Posts

    JS date range validation ??

    I have two date field viz from-date and to-date
    and i want to validate that from-date should be less than or equal to to-date
    using javascript.
    Note: date field should be in yy-mm-dd format
    How is that possible ?
    Please help me..
    Thanks in advance..

  • #2
    Senior Coder Arbitrator's Avatar
    Join Date
    Mar 2006
    Location
    Splendora, Texas, United States of America
    Posts
    3,274
    Thanks
    28
    Thanked 271 Times in 265 Posts
    You can split the date into pieces then compare them part by part. Itíll be harder if you want to compare 1900 years with 2000 years in a yy format though.
    Code:
    var fromDateSplit = fromDate.split("-");
    var toDateSplit = toDate.split("-");
    Tutorial: http://www.pageresource.com/jscript/jstring2.htm*
    * Uses some poor practice and outdated code.
    For every complex problem, there is an answer that is clear, simple, and wrong.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •