-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.html
More file actions
76 lines (66 loc) · 2.23 KB
/
example.html
File metadata and controls
76 lines (66 loc) · 2.23 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
76
<script>
ss_thank_you_message = "Thank you for signing up.";
ss_event_name = "StreamSend Signup Form";
ss_account_id = 1234;
</script>
<style>
/* class for all fields with errors */
.field-error {background: red;}
/* class for error message */
.streamsend-error {color: red; }
/* id for the streamsend form */
#streamsend_form { }
/* id for the streamsend form success message */
#streamsend_form_success {color: green; }
/* id for the email address input */
#email_address { }
/* id for the submit button */
#streamsend-submit { }
</style>
<form id="streamsend_form" name="streamsend_form" method="post">
<div>
<label>Email</label>
<input placeholder="Email" type="email" id="email_address" name="email_address" tabindex="1" autofocus />
<button type="submit" name="submit" id="streamsend-submit" tabindex="10">Send</button>
<div id="streamsend-error" class="streamsend-error"></div>
</div>
</form>
<div id="streamsend_form_success"></div>
<script src="//cdn.statstrk01.com/assets/javascripts/sdk2.js" async></script>
<script>
document.getElementById('streamsend_form').addEventListener('submit', function(event) {
StreamSendSubmit(event.target);
event.preventDefault();
function StreamSendSubmit(form) {
if (validEmail(form)) {
return false;
} else {
window._ssstats = window._ssstats || [];
_ssstats.push([
'configure', {
accountId: ss_account_id
}
]);
_ssstats.push(['identify', form.email_address.value]);
_ssstats.push(['publish', ss_event_name]);
document.getElementById('streamsend_form').innerHTML = "";
document.getElementById('streamsend_form_success').innerHTML = ss_thank_you_message;
return false;
}
}
function validEmail(form)
{
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(form.email_address.value))
{
document.getElementById('email_address').className = "";
document.getElementById('streamsend-error').innerHTML = '';
return false;
}
else {
document.getElementById('email_address').className = "field-error";
document.getElementById('streamsend-error').innerHTML = "Please enter a valid email address";
return true;
}
}
}, false);
</script>