请muxrwc帮忙看一下
<head>
<script type= "text/javascript ">
function $(id) {
return document.getElementById(id);
}
function kc(e) {
var e = window.event || e;
var o = e.srcElement || e.target;
var code = e.keyCode || e.which;
var string = String.fromCharCode(code);
var number = parseInt(string);
var num = /[^\d]/;
var ar;
if (num.test(string)) return false;
else {
switch (o.value.length) {
case 0:
case 1:
case 2:
case 4:
return true;
case 5:
if (number > 1) return false;
case 7:
case 8:
ar = o.value.split( "- ");
if (parseInt(ar[1]) == 2 && number > 2) return false;
else if (number > 3) return false;
case 9:
ar = o.value.split( "- ");
if ((parseInt(ar[1]) == 2 && parseInt(ar[0]) % 4 != 0 && number > 8) ||
(parseInt(ar[2]) == 3 && number > 1) ||
(parseInt(ar[2]) == 0 && number == 0)) return false;
return true;
case 3:
if (parseInt(o.value) == 0 && number == 0) return false;
o.value += string + "- ";
return false;
case 6:
if (parseInt(o.value.split( "- ")[1]) == 0 && number == 0) return false;
if (number > 2) return false;
o.value += string + "- ";
default:
return false;
}
}
}
window.onload = function () {
$( "wc ").onkeypress = kc;
}
</script>
</head>
<body>
<input id= "wc " />
</body>
</html>
帮忙给看一下 为什么月份无法输入03到09 谢谢
------解决方案--------------------=.=