<script type=
"text/javascript"
>
<!--
var
myDate =
new
Date();
myDate.getYear();
myDate.getFullYear();
myDate.getMonth();
myDate.getDate();
myDate.getDay();
myDate.getTime();
myDate.getHours();
myDate.getMinutes();
myDate.getSeconds();
myDate.getMilliseconds();
myDate.toLocaleDateString();
var
mytime=myDate.toLocaleTimeString();
myDate.toLocaleString( );
if
(mytime<
"23:30:00"
){
alert(mytime);
}
<pre name=
"code"
class
=
"java"
><pre name=
"code"
class
=
"java"
></script>
<script type=
"text/javascript"
>
function
check(){
<pre name=
"code"
class
=
"java"
><pre name=
"code"
class
=
"java"
><pre name=
"code"
class
=
"java"
>
var
riqi1 = document.getElementById(
"begin_time"
).value;
var
riqi2 = document.getElementById(
"end_time"
).value; </pre><pre name=
"code"
class
=
"java"
>
var
datePattern = /^(d{4})-(d{1,2})-(d{1,2})$/;
if
(riqi1 ==
""
&& riqi2 !=
""
){
if
(! datePattern.test(riqi2)) {
window.alert(
"请填写正确的 结束日期格式"
);
return
false
;
}
alert(
"请输入开始时间!"
);
return
false
;
}
if
(riqi1 !=
""
&& riqi2 ==
""
){
if
(! datePattern.test(riqi1)) {
window.alert(
"请填写正确的 开始日期格式"
);
return
false
;
}
alert(
"请输入结束时间!"
);
return
false
;
}
if
(riqi1 !=
""
&& riqi2 !=
""
){
var
datePattern = /^(d{4})-(d{1,2})-(d{1,2})$/;
if
(! datePattern.test(riqi1)) {
window.alert(
"请填写正确的 开始日期格式"
);
return
false
;
}
if
(! datePattern.test(riqi2)) {
window.alert(
"请填写正确的 结束日期格式"
);
return
false
;
}
}
var
d1 =
new
Date(riqi1.replace(/-/g,
"/"
));
var
d2 =
new
Date(riqi2.replace(/-/g,
"/"
));
if
(Date.parse(d1) - Date.parse(d2) >= 0) {
alert(
"开始时间不能早于结束时间!"
);
return
false
;
}</pre>
<pre></pre>
<pre></pre>
} </script> <BODY> 开始时间:<input type=
"text"
id=
"begin_time"
><br/>结束时间:<input type=
"text"
id=
"end_time"
><br/><input type=
"button"
onclick=
"check()"
></BODY>
<pre></pre>
<pre></pre>
<pre></pre>
<pre></pre>
<pre></pre>
<pre></pre>
<pre></pre>
<pre></pre>
<pre></pre>
<pre></pre>
<pre></pre>
<pre></pre>
</pre></pre></pre></pre>