I have a form with the fields check_in
and check_out
.
I wish that if one of the two is empty the button
" Search " disappears and only appears in case the two fields are with a date.
I have the necessary libraries included jQuery and the file where I have the jQuery code:
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css">
<script src="http://momentjs.com/downloads/moment.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<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 type="text/javascript" src="js/calculoNoches.js"></script>
HTML Code:
<label for="check_in"><b>Entrada:</b></label>
<input type="text" placeholder="Fecha de entrada" name="check_in" id="check_in" value="<?php if(isset($_POST['check_in'])){ echo $_POST['check_in']; }?>">
<label for="check_out"><b>Salida:</b></label>
<input type="text" placeholder="Fecha de salida" name="check_out" id="check_out" onchange="calculoNoches();" value="<?php if(isset($_POST['check_out'])){ echo $_POST['check_out']; }?>" disabled>
JQuery code:
$(document).on('ready',function(){
$check_in = $(this).attr("check_in");
$check_out = $(this).attr("check_out");
if($check_in == "" || $check_out == ""){
$('#buscar').hide();
}
});