Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
- <title>Ejemplo sweet alert</title>
- <link rel="stylesheet" href="css/bootstrap.css">
- <link rel="stylesheet" href="css/bootstrap-theme.css">
- <link rel="stylesheet" href="css/sweetalert.css">
- </head>
- <body>
- <main class="container">
- <div class="row">
- <div class="col-xs-4 col-xs-offset-4">
- <form id="ejemplo">
- <legend>Validación con form validation</legend>
- <div class="form-group">
- <label for="">Campo de texto</label>
- <input type="text" class="form-control" name="nombreCampo" placeholder="Input field">
- </div>
- <button type="submit" class="btn btn-primary">Enviar</button>
- </form>
- </div>
- </div>
- </main>
- <script src="js/jquery-dist.js"></script>
- <script src="js/bootstrap.js"></script>
- <script src="js/formValidation-dist.js"></script>
- <script src="js/framework/bootstrap-dist.js"></script>
- <script src="js/sweetalert.min.js"></script>
- <script type="text/javascript">
- $('#ejemplo')
- .formValidation({
- framework: 'bootstrap',
- fields: {
- nombreCampo: {
- validators: {
- notEmpty: {
- message: 'Campo vacio.'
- },
- stringLength: {
- min:4,
- message: 'Minimo de 4 caracteres.'
- }
- }
- }
- }
- })
- .on('success.form.fv', function(e){
- e.preventDefault();
- var $form = $(e.target);
- var fv = $form.data('formValidation');
- swal({
- title: "Are you sure?",
- text: "You will not be able to recover this imaginary file!",
- type: "warning",
- showCancelButton: true,
- confirmButtonColor: "#DD6B55",
- confirmButtonText: "Yes, delete it!",
- closeOnConfirm: false },
- function(){
- swal({
- title: "Se envio con éxito",
- closeOnConfirm: false
- },
- function(){
- fv.defaultSubmit()
- })
- });
- });
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment