zoukankan      html  css  js  c++  java
  • js简单实现输入年月日,并显示出结果

    var year=prompt("美女,请输入年份");
    if(year!=null)
    {
    if(isNaN(year))
    {
    alert("美女,输入的不是数字");
    }
    else
    {
    if(isNum(year))
    {
    if(year>0&&year<=9999)
    {
    var month=prompt("美女,请输入月份");
    if(month!=null)
    {
    if(isNaN(month))
    {
    alert("笨蛋,不是数字");
    }
    else
    {
    if(isNum(month))
    {
    if(month>=1&&month<=12)
    {
    var day=prompt("请输入年月日的日");
    if(isNaN(day))
    {
    alert("不是数字");
    }
    else
    {
    if(isNum(day))
    {
    if(day>=1&&day<=31)
    {
    if(month==2)
    {
    if(day>=1&&day<=28)
    {
    alert("您输入的年月日为:"+year+"年"+month+"月"+day+"日");
    }
    else if(day==30|day==31)
    {
    alert("2月份没有30号或者31号");
    }
    else if(day==29)
    {
    if((year%4==0&&year%10!=0)|year%400==0)
    {
    alert("您输入的年月日为:"+year+"年"+month+"月"+day+"日");
    }
    else
    {
    alert("小子,平年是没有29号的");
    }
    }
    }
    else if(month==1||month==3||month==5||month==7||month==8||month==10||month==12)
    {
    alert("您输入的年月日为:"+year+"年"+month+"月"+day+"日");
    }
    else if(month==4||month==6||month==9||month==11)
    {
    if(day==31)
    {
    alert("4,6,9,11月没有31号");
    }
    else
    {
    alert("您输入的年月日为:"+year+"年"+month+"月"+day+"日");
    }
    }
    }
    else
    {
    alert("日只能在1-31之间");
    }
    }
    else
    {
    alert("请不要输入小数");
    }
    }
    }
    else
    {
    alert("月份只有1-12哦");
    }
    }
    else
    {
    alert("请不要输入小数");
    }
    }
    }
    else
    {
    alert("小子,记不住吗,不要乱点");
    }

    }
    else
    {
    alert("不好意思,我们有规定,输入的整数必须是大于0小于等于9999");
    }
    }
    else
    {
    alert("小子,这是小数!");
    }
    }
    }
    else
    {
    alert("小子,不要乱点");
    }


    function isNum(s)
    {
    var regu = "^([0-9]*[.0-9])$"; // 小数测试
    var re = new RegExp(regu);
    if (s.search(re) != -1)
    return true;
    else
    return false;
    }

  • 相关阅读:
    Qt的.pro文件
    AI_八数码
    安装 MINGW GCC 4.4.0
    VC中应用Excel
    八数码问题_启发搜索
    【收集】【收藏】【转帖】game development resouce
    QT小记之在VS2005中使用QT
    [转文]VS2008 安装 Boost 1.43.0
    搬家到博客园了
    转 暴雪总裁总结游戏十条经验
  • 原文地址:https://www.cnblogs.com/kaililikai/p/5800070.html
Copyright © 2011-2022 走看看