Tengo un formulario con los campos check_in
y check_out
.
Deseo que si alguno de los dos está vacío desaparezca el button
"Buscar" y sólo aparezca en caso de que los dos campos están con una fecha.
Tengo incluidas las librerías necesarias como jQuery y el archivo donde tengo el código jQuery:
<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>
Código HTML:
<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>
Código jQuery:
$(document).on('ready',function(){
$check_in = $(this).attr("check_in");
$check_out = $(this).attr("check_out");
if($check_in == "" || $check_out == ""){
$('#buscar').hide();
}
});