-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
61 lines (52 loc) · 1.82 KB
/
script.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
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
function getURLParameter(name) {
return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search) || [null, ''])[1].replace(/\+/g, '%20')) || null;
}
function validateEmail(email) {
var 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,}))$/;
return re.test(String(email).toLowerCase());
}
function openMenu() {
$("#menu").css("left", "0");
$("#menuBackground").fadeIn(1000);
}
function closeMenu() {
$("#menu").css("left", "-75vw");
$("#menuBackground").fadeOut(1000);
closeAlert();
}
$(function() {
$("input[type='email']").each(function() {
$(this).next().children().css({
"padding-left": "315px",
"width": "0px"
});
var thisRef = this;
setTimeout(function() {$(thisRef).next().children().css("transition", "1s");}, 100);
$(this).focus(function() {
$(this).next().children().css({
"padding-left": "0px",
"width": "305px"
});
});
$(this).blur(function() {
if ($(this).val() == "") {
$(this).next().children().css({
"padding-left": "315px",
"width": "0px"
});
} else {
$(this).next().children().css({
"padding-left": "0px",
"width": "305px"
});
}
});
$(this).on("input", function() {
if ($(this).val() != "" && !validateEmail($(this).val() + "@norwich-school.org.uk")) {
$(this).css("color", "red");
} else {
$(this).css("color", "black");
}
});
});
});