time hh:mm validation

by padma rubhan

HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="text" id="nohrs" maxLength="5" />

JavaScript

$("#nohrs").blur(function() {
var value = $(this).val();
var re = /[0-9][0-9]:[0-9][0-9]/;
 if (value.match(re)) {
 }
 else{
  $("#nohrs").val('');
  alert('Enter the valid time format as HH:MM');
 }
});