$(document).ready(function() {
    
	
	
	    $('#CambioClave_form').bootstrapValidator({
        // To use feedback icons, ensure that you use Bootstrap v3.1.0 or later
        feedbackIcons: {
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        },
        fields: {
            txtClaveNueva: {
                validators: {
                        stringLength: {
                        min: 8,
                    },
                        notEmpty: {
                        message: 'Por favor Digite una nueva clave'
                    }
                }
            },
             txtConfirmarClave: {
                validators: {
                     stringLength: {
                        min: 8,
                    },
                    notEmpty: {
                        message: 'Por favor confirme su nueva clave'
                    }
                }
            }
           }
        })
        .on('success.form.bv', function(e) {
            //$('#success_message').slideDown({ opacity: "show" }, "slow") // Do something ...
                $('#CambioClave_form').data('bootstrapValidator').resetForm();

            // Prevent form submission
            e.preventDefault();

            // Get the form instance
            var $form = $(e.target);

            // Get the BootstrapValidator instance
            var bv = $form.data('bootstrapValidator');

            // Use Ajax to submit form data
			var sbNewClave = $("#txtClaveNueva").val();
			var sbNewClave2 = $("#txtConfirmarClave").val();
			
			if (sbNewClave == sbNewClave2){
					//$.post($form.attr('action'), $form.serialize(), function(result) {}, 'json');
					$.getJSON( "../src/upd_clave.php", {sbNewClave:sbNewClave}, function( data ){
					  console.log("debio actualizar 1" , data);
					});
					parent.location="../index.php";					
					alert("Cambio de contraseña, Exitoso !");
			}else
			{
				$('#CambioClave_form').data('bootstrapValidator').resetForm();
				alert("Las contraseñas no coinciden, por favor verificar");
			}
        });
		
		
		
		
});