Blok tanggal sebelum hari ini

Biar input type date tidak membolehkan select hari sebelum hari ini (kemarin dan kebelakangnya) itu gimana ya ?

avatar dimashpt
@dimashpt

39 Kontribusi 1 Poin

Diperbarui 6 tahun yang lalu

2 Jawaban:

Coba ini gan:


var pilihHari = '2012-11-03';

if( (new Date().getTime() > new Date(pilihHari).getTime()))
{
   //Tidak Boleh Select
} else {
   //Boleh Select
}

source: [link]https://stackoverflow.com/questions/11170054/compare-dates-with-javascript [/link] https://stackoverflow.com/questions/338463/how-do-i-do-a-date-comparison-in-javascript https://www.c-sharpcorner.com/UploadFile/8911c4/how-to-compare-two-dates-using-javascript/

avatar keccikun
@keccikun

364 Kontribusi 196 Poin

Dipost 6 tahun yang lalu

pake datepicker jquery? coba pake ini

 <!DOCTYPE html>
<html>
<head>
	<title></title>
	  <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
	  <link rel="stylesheet" href="/resources/demos/style.css">
	  <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
	  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
	  <script>
	  $( function() {
	    $( "#datepicker" ).datepicker(
	    	{minDate: new Date(),}
	    );
	  } );
	  </script>
</head>
<body>
<form id="form" method="post">
	<input type="text" name="tgl" id="datepicker">
</form>
</body>
</html>
avatar dianarifr
@dianarifr

642 Kontribusi 316 Poin

Dipost 6 tahun yang lalu

Login untuk ikut Jawaban