<form id="form1" name="form1" method="post" action="">
<input type="text" name="houript" id="houript" style="width:25px" onKeyUp="value=value.replace(/[^/d]/g,'');" value="" size="18" maxLength="2" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^/d]/g,''))"/>
<strong>:</strong>
<input type="text" name="secondipt" id="secondipt" style="width:25px" onKeyUp="value=value.replace(/[^/d]/g,'');checksecond(this);" value="" size="18" maxLength="2" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^/d]/g,''))"/>
<input type="button" name="ddd" value="dddd" οnclick='checktimeinput("houript","secondipt")'/>
</form>
<script language="javascript" type="text/javascript">
var hour_ok=false;
var second_ok=false;
function checkhour(ele){
if(ele.value==""){
alert("請輸入小時!");
ele.focus();
selectThisText(ele);
}else if(!check_int(ele.id)||parseInt(ele.value)<0||parseInt(ele.value)>23){
alert("請輸入0~23的數字");
ele.focus();
selectThisText(ele);
}else
hour_ok=true;
}
function checksecond(ele){
if(ele.value==""){
alert("請輸入分鐘!");
ele.focus();
}else if(!check_int(ele.id)||parseInt(ele.value)<0||parseInt(ele.value)>23){
alert("請輸入0~59的數字");
ele.focus();
}else
second_ok=true;
}
function checktimeinput(hour,second){
var h_e=gid(hour);
var s_e=gid(second);
checkhour(h_e);
if(hour_ok==false) return false;
checksecond(s_e);
if(second_ok==false) return false;
return true;
}
function selectThisText(element){
if(window.getSelection){
var txt=element.value;
element.setSelectionRange(0,txt.length);
}else{
var range=element.createTextRange();
// range.moveToElementText(element);
range.select();
}
}