zoukankan      html  css  js  c++  java
  • 判断日期格式是否正确

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>日期设置</title>
    </head>

    <body>
    </body>
    </html>
    分别输入年、月、日。判断日期格式是否正确!!!
    <script type="text/javascript">
    var year =prompt("请输入一个年份")
    if(year!=null)
    {
    var year1=isNaN(year)
    if(year1==false)
    {
    if(year%1==0&&year>0&&year<9999)
    {
    var month=prompt("请输入月份")
    if(month!=null)
    {
    var month1=isNaN(month)
    if(month1==false)
    {
    if(month%1==0&&month>0&&month<=12)
    {
    var date=prompt("请输入日期")
    if(date!=null)
    {
    var date1=isNaN(date)
    if(date1==false)
    {
    if(date%1==0&&date>0&&date<=31)
    {
    if(month==1||month==3||month==5||month==7||month==8||month==10||month==12)
    {
    alert("日期格式输入正确,您输入的日期为"+year+"年"+month+"月"+date+"日。")
    }
    else if(month==4||month==6||month==9||month==11)

    {
    if (date<31)

    {
    alert("日期格式输入正确,您输入的日期为"+year+"年"+month+"月"+date+"日。")
    }
    else{alert("日期格式输入正确,您输入的日期为"+year+"年"+month+"月"+date+"日。")}
    }
    else(month==2)
    {
    if(year%4==0&&year%100!=0||year%400==0)
    {
    if(date>0&&date<=29)
    {
    alert("日期格式输入正确,您输入的日期为"+year+"年"+month+"月"+date+"日。")
    }
    else
    {
    alert("输入有误")
    } }
    else
    {
    if(date>0&&date<=28)
    {
    alert(year+"-"+month+"-"+date)
    }
    else
    {
    alert("输入有误")
    }
    }
    }
    }
    else
    {
    alert("输入有误")
    }
    }
    else
    {
    alert("输入有误")
    }
    }
    }
    else
    {
    alert("输入有误")
    }
    }
    else
    {
    alert("输入有误")
    }
    }
    }
    else
    {
    alert("输入有误")
    }
    }
    else
    {
    alert("输入有误")
    }
    }


    </script>

  • 相关阅读:
    Install OpenCV 3.0 and Python 2.7+ on OSX
    Install OpenCV 3.0 and Python 2.7+ on Ubuntu
    完美商业计划书全攻略
    No module named zope.interface error的解决
    nginx flv点播服务器搭建
    关于Apple开发者的D-U-N-S Number
    小而美的Promise库——promiz源码浅析
    为什么JavaScript里面0.1+0.2 === 0.3是false
    JavaScript取出字符串中括号里的内容
    js数据结构与算法--递归
  • 原文地址:https://www.cnblogs.com/smile-dream/p/5802176.html
Copyright © 2011-2022 走看看