source: prototipo_portal_2018/prototipo/static/js/contact_me.js @ 025e022

Last change on this file since 025e022 was 747e744, checked in by Antonio Araujo <aaraujo@…>, 7 years ago

Creado directorio prototipo con fuentes de la modificación del portal para establecer la ubicación de la firma visible

  • Property mode set to 100644
File size: 2.8 KB
Line 
1// Contact Form Scripts
2
3$(function() {
4
5    $("#contactForm input,#contactForm textarea").jqBootstrapValidation({
6        preventSubmit: true,
7        submitError: function($form, event, errors) {
8            // additional error messages or events
9        },
10        submitSuccess: function($form, event) {
11            event.preventDefault(); // prevent default submit behaviour
12            // get values from FORM
13            var name = $("input#name").val();
14            var email = $("input#email").val();
15            var phone = $("input#phone").val();
16            var message = $("textarea#message").val();
17            var firstName = name; // For Success/Failure Message
18            // Check for white space in name for Success/Fail message
19            if (firstName.indexOf(' ') >= 0) {
20                firstName = name.split(' ').slice(0, -1).join(' ');
21            }
22            $.ajax({
23                url: "././mail/contact_me.php",
24                type: "POST",
25                data: {
26                    name: name,
27                    phone: phone,
28                    email: email,
29                    message: message
30                },
31                cache: false,
32                success: function() {
33                    // Success message
34                    $('#success').html("<div class='alert alert-success'>");
35                    $('#success > .alert-success').html("<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;")
36                        .append("</button>");
37                    $('#success > .alert-success')
38                        .append("<strong>Your message has been sent. </strong>");
39                    $('#success > .alert-success')
40                        .append('</div>');
41
42                    //clear all fields
43                    $('#contactForm').trigger("reset");
44                },
45                error: function() {
46                    // Fail message
47                    $('#success').html("<div class='alert alert-danger'>");
48                    $('#success > .alert-danger').html("<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;")
49                        .append("</button>");
50                    $('#success > .alert-danger').append("<strong>Sorry " + firstName + ", it seems that my mail server is not responding. Please try again later!");
51                    $('#success > .alert-danger').append('</div>');
52                    //clear all fields
53                    $('#contactForm').trigger("reset");
54                },
55            });
56        },
57        filter: function() {
58            return $(this).is(":visible");
59        },
60    });
61
62    $("a[data-toggle=\"tab\"]").click(function(e) {
63        e.preventDefault();
64        $(this).tab("show");
65    });
66});
67
68
69/*When clicking on Full hide fail/success boxes */
70$('#name').focus(function() {
71    $('#success').html('');
72});
Note: See TracBrowser for help on using the repository browser.