function validar(){
    event.preventDefault(); 
    var frm = document.getElementById('form');
    var data = new FormData(frm);
    var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function () {
        if (this.readyState == 4) {
            var msg = xhttp.responseText;
            if (msg == 'success') {
                $.confirm({
                  title: 'Guardado',
                  content: 'Con Exito!',
                  theme: 'modern',
                  buttons: {
                      OK: function () {
                        $('#form').trigger('reset');  
                      },
                  }

              });                
            } else {
                $.alert({
                    title: 'Erro al Guardar!',
                   content: 'Verificar',
                    theme: 'modern'
                });
            }

        }
    };
    xhttp.open("POST", "data/insert_programa.php", true);
    xhttp.send(data);
 };

 