-
Notifications
You must be signed in to change notification settings - Fork 0
/
custom.js
29 lines (28 loc) · 1.1 KB
/
custom.js
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
'use strict'
$( document ).ready(function() {
Parse.initialize("hURi3JLB3HegEFsSplfjjmeyEzup0xk5BWSp6q6U", "mK7YFExlvlH85Exau5LaujOWxZEC6tvBIdugjgRN");
$("#signup").submit(function(e) {
e.preventDefault();
var email_re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
var name_input = $('#name-field').val();
var email_input = $('#email-field').val();
if (name_input != null && name_input != "") {
if(email_re.test(email_input) ) {
$('submit-button').html('Saving...');
var Lead = Parse.Object.extend("Lead");
var lead = new Lead();
lead.save({name: name_input, email: email_input}).then(function(object) {
$('#form-wrapper').addClass('hidden');
$('#success-message').removeClass('hidden');
});
} else {
$('#email-field').addClass('error');
}
} else {
$('#name-field').addClass('error');
if(!email_re.test(email_input) ) {
$('#email-field').addClass('error');
}
}
});
});