I am trying to validate that the select with ajax is not empty but I can not find the form, I have tried several ways but nothing.
<form method="post" id="formulario">
<div class="form-group">
<select class="form-control" name="form" id="form">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
<br>
<input type="button" id="options" value="enviar" class="btn btn-danger" />
</div>
</form>
<div id="resultado"></div>
<script>
$(document).on('ready',function(){
$('#report').click(function(){
var url = "documento.php";
if($("#form").val() == 0) {
alert("Debe Seleccionar una opcion");
return false;
}
$.ajax({
type: "POST",
url: url,
data: $("#formulario").serialize(),
success: function(data)
{
$("#formulario").hide();
$('#resultado').html(data);
}
});
});
});
</script>
Of the multiple forms the ajax ignores it and it realizes the request to me in empty.