Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert Colon

Status
Not open for further replies.

lesleint

IS-IT--Management
Apr 11, 2003
144
US
Can someone please help me create a function that would insert a colon for the user when typing a time out

So if the user types 130 onBlur it would change it to
1:30
and same goes for 1230 to 12:30
 
I got it,
Code:
function setColon()
{
var strTime = document.caseLog.time.value;
var strTimeL = strTime.length

if (strTimeL==4)
{
document.caseLog.time.value = strTime.substr(0,2) + ':' + strTime.substr(2,4)
}
if (strTimeL==3)
{
document.caseLog.time.value = strTime.substr(0,1) + ':' + strTime.substr(1,3)
}
}
Got to love w3schools.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top