Skip to content

Commit

Permalink
(chore) Hide form on landing page
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Gichuri committed Apr 30, 2016
1 parent a5a5cc3 commit badc06d
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions public/js/script.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
$(function () {

$(".button-collapse").sideNav();

$('#p').hide();
// GET function
$(document).on('click', '#get-button', function() {
$.ajax({
Expand Down Expand Up @@ -36,7 +36,11 @@ $(function () {
// If user has not filled form
if (!attendee || !email) {
Materialize.toast('Please fill in both fields', 4000);
} else {
}
else if (!validateEmail(email)) {
Materialize.toast('Please enter a valid email address', 4000);
}
else {
// Post value if user has filled name
$.ajax({
url: '/api/save',
Expand Down Expand Up @@ -76,4 +80,14 @@ $(function () {
$('#sidenav-overlay').hide();
$('.button-collapse').hide();
});

function validateEmail(email) {
var reg = /^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/
if (reg.test(email)) {
return true;
} else {
return false;
}
}

});

0 comments on commit badc06d

Please sign in to comment.