INPUT TYPE ONLY TIME WITHOUT Am AND Pm
<html>
<head>
<title></title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(document).ready(function()
{
$("#timer").attr({ maxLength : 8 });
$("#timer").keypress(function(e)
{
if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57))
{
return false;
}
if($(this).val().length == 2)
{
$val=$(this).val();
$(this).val($val+':');
}
if($(this).val().length == 5)
{
$val=$(this).val();
$(this).val($val+':');
}
});
});
</script>
</head>
<body>
<input type="text" placeholder="00:00:00" step="3" id="timer"/>
</body>
</html>
<head>
<title></title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(document).ready(function()
{
$("#timer").attr({ maxLength : 8 });
$("#timer").keypress(function(e)
{
if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57))
{
return false;
}
if($(this).val().length == 2)
{
$val=$(this).val();
$(this).val($val+':');
}
if($(this).val().length == 5)
{
$val=$(this).val();
$(this).val($val+':');
}
});
});
</script>
</head>
<body>
<input type="text" placeholder="00:00:00" step="3" id="timer"/>
</body>
</html>
Comments
Post a Comment