-
Notifications
You must be signed in to change notification settings - Fork 8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1682 from Anjaszz/master
Add files via upload
- Loading branch information
Showing
1 changed file
with
67 additions
and
0 deletions.
There are no files selected for viewing
67 changes: 67 additions & 0 deletions
67
Program's_Contributed_By_Contributors/JavaScript_Programs/contact_me.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
$(function() { | ||
|
||
$("input,textarea").jqBootstrapValidation({ | ||
preventSubmit: true, | ||
submitError: function($form, event, errors) { | ||
|
||
}, | ||
submitSuccess: function($form, event) { | ||
event.preventDefault(); | ||
var name = $("input#name").val(); | ||
var email = $("input#email").val(); | ||
var message = $("textarea#message").val(); | ||
var firstName = name; | ||
|
||
if (firstName.indexOf(' ') >= 0) { | ||
firstName = name.split(' ').slice(0, -1).join(' '); | ||
} | ||
$.ajax({ | ||
url: "././mail/contact_me.php", | ||
type: "POST", | ||
data: { | ||
name: name, | ||
email: email, | ||
message: message | ||
}, | ||
cache: false, | ||
success: function() { | ||
|
||
$('#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>'); | ||
|
||
|
||
$('#contactForm').trigger("reset"); | ||
}, | ||
error: function() { | ||
|
||
$('#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>'); | ||
|
||
$('#contactForm').trigger("reset"); | ||
}, | ||
}) | ||
}, | ||
filter: function() { | ||
return $(this).is(":visible"); | ||
}, | ||
}); | ||
|
||
$("a[data-toggle=\"tab\"]").click(function(e) { | ||
e.preventDefault(); | ||
$(this).tab("show"); | ||
}); | ||
}); | ||
|
||
|
||
|
||
$('#name').focus(function() { | ||
$('#success').html(''); | ||
}); |