Created
December 14, 2013 04:34
-
-
Save devluis/7955716 to your computer and use it in GitHub Desktop.
Add separator in string time with jquery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Add separator in time with Jquery</title> | |
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> | |
<script> | |
$(document).ready(function() { | |
$("#currentTime").keyup(function(){ | |
if ($(this).val().length == 2){ | |
$(this).val($(this).val() + ":"); | |
}else if ($(this).val().length == 5){ | |
$(this).val($(this).val() + ":"); | |
} | |
}); | |
}); | |
</script> | |
</head> | |
<body> | |
<form id="myForm"> | |
<input type="text" name="currentTime" id="currentTime" maxlength="8"> | |
</form> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment