Javascript date verification: input date greater than or equal to current date _ javascript tips-js tutorial

Source: Internet
Author: User
This article mainly introduces the javascript date verification input date is greater than or equal to the current date, you can refer to the example of this article to analyze the javascript input date is greater than or equal to the current date verification code, we will share this with you for your reference. The details are as follows:

Script $ (function () {var d = new Date (); var strDate = getDateStr (d); $ ("# beginTime "). val (strDate); $ ("# endTime "). val (strDate); // $ ("# beginTime "). val ("2015-10-10"); $ ("# beginTime "). change (function () {var d2 = new Date ($ ("# beginTime "). val (); if (d2 <d) {alert ("the start date must be later than the current date. "); $ (" # beginTime "). val (strDate) ;}}); $ ("# endTime "). change (function () {var d2 = new Date ($ ("# beginTime "). val (); var d3 = new Date ($ ("# endTime "). val (); if (d3 <d2) {alert ("the completion date cannot be earlier than the start date. "); $ (" # endTime "). val (getDateStr (d2) ;}}) ;}); function getDateStr (date) {var month = date. getMonth () + 1; var strDate = date. getFullYear () + '-' + month + '-' + date. getDate (); return strDate;} script

I hope this article will help you design JavaScript programs.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.