I have one input field for time entry and it needs to enter hour and minute in hh:mm
format. Only numbers can be allowed and additional unnecessary data are restricted. So could you have some solution for this issue using javascript or jquery or something that will be 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;
}
};
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.