I have a JavaScript function that does a data validation, the problem is using alerts to warn when data is wrong. What I want to do is show Bootstrap modal windows to see the error. This is what I did, it does not work.
var contador = somevalue;
window.validar = function (cual){
if(cual.value == -1){
}
if($("#muestragrafico1").is(':checked')){
var cantidad = 3;
}else{
var cantidad = 1;
}
if(cual.checked){
contador++;
}else{
contador--;
}
if(contador <= cantidad){
return true;
}else{
if (cantidad == 3) {
//alert("Solo puede seleccionar un máximo de "+cantidad+" sensores.");
$('#myModalExito').modal('show');
}
if (cantidad == 1) {
alert("Solo puede seleccionar un máximo de "+cantidad+" sensores.");
}
contador--;
return false;
}
}`
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title"><?php echo L::Ticket_Succes?></h4> </div>
</div>
</div>
document.ready()function?myModalExitoas an id to your modal?