Checkbox validated and show popup

0

I explain, it happens that I want that when you accept the terms and conditions, and when you enter, show me the pop up integrated in the button, but it happens the opposite or in disorder, without chulear the checkbox or being chuleado, if or if you show me the integrated pop up.

<form method="POST" action="">
     <input type="checkbox" name="aceptar" id="aceptar" >
     Acepto terminos y condiciones 
  </form>

   <button id="enviar" type="button" title="gifdpopbox_818182126315709_df0d42dea">
     <span>Entrar</span>
     </button>

And to validate the checkbox with JS I have the following:

       $(function() { $("#enviar").click(function(event){
    var seleccion = $("#aceptar")[0].checked;
    if(!seleccion){
        event.preventDefault();
        alert("Acepta las condiciones");
    }
});

});

The idea is that if the terms are not accepted, do not show anything, it will only show when the terms are accepted and then click on Enter

Thanks

    
asked by Horiuko Kun 27.04.2018 в 00:04
source

1 answer

0

I hope I help you

<form method="POST" action="">
    <input id="check" type="checkbox" name="aceptar" id="aceptar" >
    Acepto terminos y condiciones 
</form>

<button id="enviar" type="button" title="gifdpopbox_818182126315709_df0d42dea" onclick="valida();">
    <span>Entrar</span>
</button>

function valid () {

var valida = document.getElementById("check").checked;

if(valida==true){
    alert("Acepta las condiciones");
}else{
    alert("no acepta");
}

}

    
answered by 27.04.2018 в 01:40