Hello guys I want to restrict user from entering date manually in an input field in HTML. I want user to select date from the date-picker provided to avoid input date entry
Here is the my code in which I've used date-picker.
<!DOCTYPE html>
<html class="html">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"> </script>
<link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/jquery.ui/1.10.4/themes/redmond/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"> </script>
<script>
$(function() {
$("#datepicker").datepicker(
{
dateFormat:'dd-mm-yy',
changeMonth: true,
changeYear: true,
});
});
</script>
<style>
.date-picker{
width: 250px;
height: 30px;
font-size: 18px;
padding-left: 7px;
margin-top: 10px;
margin-left: 145px;
border: 1px solid grey;
border-radius: 5px;
}
</style>
</head>
<body class="body">
<div class="date-picker-container">
<input class="date-picker" id="datepicker" placeholder="Date Of Birth">
</div>
</form>
</body>
</html>
Please help me I'm stuck with this date validation issue.
readonlyto your input<input readonly />this will avoid entering date manually by user.