javascript - How to prevent input values of hour and minute in specific format (hh:mm) -
i have 1 input field time entry , needs enter hour , minute in hh:mm
format. numbers can allowed , additional unnecessary data restricted. have solution issue using javascript or jquery or ok. thank you.
<form> <input pattern="\d{1,2}:\d{1,2}" id="date" required="required" maxlength="5"> <input type="submit"> </form>
scrpit
$(document).ready(function(){ $('#date').keypress(validatenumber); }); function validatenumber(event) { var key = window.event ? event.keycode : event.which; if (key < 48 || key > 58) { return false; } else { return true; } };
wiki
Comments
Post a Comment