Jump to content

only allowing time to be inserted into textbox


runnerjp

Recommended Posts

currently i have

function checkit(which) {
var tim = which.value;
var flag = 0;
if (!/^\d{1,2}[-:\.]\d{2}/.test(tim)) {  // basic format
flag = 1;
}
tim = tim.replace(/[-\.]/g,":");
tim = tim.split(/:/);
if ((tim[0] > 23) || tim[1] > 59) {  // hour or minute values too great
flag = 1;
}

if (flag == 1) {
alert ("This field requires a valid time!" );
which.value = "";
which.focus();
return false;
}

}

 

but the thing is it wont allow i time such as 45.6's to be entred...how could i chnage this?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.