validation date type

  1. function checkStartDate() {
  2.         var tmpDateValue = document.form1.startdate.value;
  3.         var tmpLength = tmpDateValue.length;
  4.         if (tmpLength == 0) {
  5.             alert("请u25353 照u26684 式u-28781 入u26085 期yyyy-mm-dd)。);
  6.             return false;
  7.         }
  8.         for ( var i = 0; i < tmpLength; i++) {
  9.             aChar = tmpDateValue.substring(i, i + 1);
  10.             if (aChar != "-" && (aChar < "0" || aChar > "9")) {
  11.                 alert("请u25353 照u26684 式u-28781 入u26085 期yyyy-mm-dd)。);
  12.                 return false;
  13.             }
  14.         }
  15.         if ((tmpLength < 8 || tmpLength > 10) && tmpLength != 0) {
  16.             alert("请u25353 照u26684 式u-28781 入u26085 期yyyy-mm-dd)。);
  17.             return false;
  18.         }
  19.         for ( var j = 0; j < 4; j++) {
  20.             aChar = tmpDateValue.substring(j, j + 1);
  21.             if (aChar < "0" || aChar > "9") {
  22.                 alert("请u25353 照u26684 式u-28781 入u26085 期yyyy-mm-dd)。);
  23.                 return false;
  24.             }
  25.         }
  26.         if (tmpDateValue.substring(4, 5) != "-"
  27.                 || tmpDateValue.substring(5, 6) == "-") {
  28.             alert("请u25353 规u23450 格u24335 输u20837 日u26399 (yyyy-mm-dd)。);
  29.             return false;
  30.         }
  31.         if (tmpLength == 8) {
  32.             if (tmpDateValue.substring(6, 7) != "-"
  33.                     || tmpDateValue.substring(7, 8) == "-") {
  34.                 alert("请u25353 规u23450 格u24335 输u20837 日u26399 (yyyy-mm-dd)。);
  35.                 return false;
  36.             }
  37.         }
  38.         if (tmpLength == 9) {
  39.             if (tmpDateValue.substring(8, 9) == "-") {
  40.                 alert("请u25353 规u23450 格u24335 输u20837 日u26399 (yyyy-mm-dd)。);
  41.                 return false;
  42.             }
  43.         }
  44.         if (tmpLength == 10) {
  45.             if (tmpDateValue.substring(7, 8) != "-"
  46.                     || tmpDateValue.substring(6, 7) == "-"
  47.                     || tmpDateValue.substring(8, 9) == "-"
  48.                     || tmpDateValue.substring(9, 10) == "-") {
  49.                 alert("请u25353 规u23450 格u24335 输u20837 日u26399 (yyyy-mm-dd)。);
  50.                 return false;
  51.             }
  52.         }
  53.         var count = 0;
  54.         for ( var k = 0; k < tmpLength; k++) {
  55.             aChar = tmpDateValue.substring(k, k + 1);
  56.             if (aChar == "-") {
  57.                 count++;
  58.             }
  59.         }
  60.         if (count != 2) {
  61.             alert("请u25353 照u26684 式u-28781 入u26085 期(yyyy-m-dd)");
  62.             return false;
  63.         }
  64.         return true;
  65.     }
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值