-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
75 lines (69 loc) · 3.14 KB
/
script.js
File metadata and controls
75 lines (69 loc) · 3.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
$(function() {
// $("input,textarea").jqBootstrapValidation({
// preventSubmit: true,
// submitError: function($form, event, errors) {
// // additional error messages or events
// },
// submitSuccess: function($form, event) {
// event.preventDefault(); // prevent default submit behaviour
// // get values from FORM
document.getElementById("submit").addEventListener("click",()=>{
var name = $("input#name").val();
var email = $("input#email").val();
var phone = $("input#phone").val();
var instName = $("input#instName").val();
// var firstName = name; // For Success/Failure Message
// // Check for white space in name for Success/Fail message
// if (firstName.indexOf(' ') >= 0) {
// firstName = name.split(' ').slice(0, -1).join(' ');
// }
$.ajax({
url: "https://script.google.com/macros/s/AKfycbzhbZbJS889aq6bBXSNdyVbk6B-7xDgti9_u1kby5QskRwjNn2Ce8S3On_fU_ITCxzJ/exec",
type: "POST",
data: {
name: name,
_subject: 'Register',
email: email,
phone: phone,
instName: instName,
},
cache: false,
success: function(data) {
console.log(data)
// Success message
$('#success').html("<div class='alert alert-success'>");
// $('#success > .alert-success').html("<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×")
// .append("</button>");
$('#success > .alert-success')
.append("<strong>Your message has been sent. </strong>");
$('#success > .alert-success')
.append('</div>');
//clear all fields
$('#registerForm').trigger("reset");
},
error: function(err) {
// Fail message
$('#success').html("<div class='alert alert-danger'>");
$('#success > .alert-danger').html("<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×")
.append("</button>");
$('#success > .alert-danger').append("<strong>Sorry " + firstName + ", it seems that my mail server is not responding. Please try again later!");
$('#success > .alert-danger').append('</div>');
//clear all fields
$('#registerForm').trigger("reset");
},
})
})
// },
// filter: function() {
// return $(this).is(":visible");
// },
});
// $("a[data-toggle=\"tab\"]").click(function(e) {
// e.preventDefault();
// $(this).tab("show");
// });
// });
/*When clicking on Full hide fail/success boxes */
// $('#name').focus(function() {
// $('#success').html('');
// });