-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjquery.js
106 lines (96 loc) · 3.79 KB
/
jquery.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
var dic = {}
dic['a'] = 'a'; // init the dic with the user a and password a for testing
//validate all the fields in regesteration.
$(document).ready(function() {
$("#register").click(function() {
var user_name = $("#user_name").val();
var first_name = $("#first_name").val();
var last_name = $("#last_name").val();
var email = $("#email").val();
var password = $("#password").val();
var date = $("#date").val();
if (user_name == '' || first_name == ''||last_name == ''||
email == '' || password == '' || date == '') {
alert("Please fill all fields!!");
} else if ((password.length) < 8) {
alert("Password should at least 8 character in length!! for your protection");
} else if (!(password).match(/[A-z]/) || !(password).match(/\d/)) {
alert("Your passwords must conatin at least 1 number and letter!");
} else if((first_name.match(/\d/))){
alert("Your first name should contain 0 numbers!");
} else if((last_name.match(/\d/))){
alert("Your last name should contain 0 numbers!");
} else if((!validateEmail(email))){
alert("enter a proper email!");
} else {
dic[user_name] = password;
$("#user_name").val('');
$("#first_name").val('');
$("#last_name").val('');
$("#email").val('');
$("#password").val('');
$("#date").val('');
ShowSection('login_div');
}
});
});
$('#ex1').slider({
formatter: function(value) {
return 'Current value: ' + value;
}
});
$(document).ready(function() {
$("#btn2").click(function() {
$("#login_user_name").val('');
$("#login_password").val('');
});
});
$(document).ready(function() {
$("#btn3").click(function() {
$("#user_name").val('');
$("#first_name").val('');
$("#last_name").val('');
$("#email").val('');
$("#password").val('');
$("#date").val('');
});
});
$(document).ready(function() {
$("#login").click(function() {
var user_name = $("#login_user_name").val();
lblUser.value = user_name;
var password = $("#login_password").val();
if (!(user_name in dic)){
alert("no such user!")
}
else if(dic[user_name]!= password){
alert("not the right password");
} else {
$("#login_user_name").val('');
$("#login_password").val('');
ShowSection('instructions_div');
}
});
});
$(document).ready(function() {
$("#Play").click(function() {
var ballsCounter = $("#myRange").val();
var timeToPlay = $("#TimeLimit").val();
var enemyCounter = $("#selectMonsters").val();
if(parseInt(timeToPlay) < 60){
alert("Please pick a time of at least 60");
}
else {
ShowSection('canvas_div');
Start(ballsCounter, timeToPlay, enemyCounter); // should trasfrom to the game screen
}
});
});
function validateEmail(sEmail) {
var filter = new RegExp(/^[+a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,4}$/i);;
if (filter.test(sEmail)) {
return true;
} else {
return false;
}
}