-
Notifications
You must be signed in to change notification settings - Fork 0
/
myscript.js
126 lines (113 loc) · 2.95 KB
/
myscript.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
$('#queryemail').keypress(function(key) {
$('#emailError').fadeOut(500);
});
$('#queryname').keypress(function(key) {
$('#nameError').fadeOut(500);
});
$('#querysubject').keypress(function(key) {
$('#subjectError').fadeOut(500);
});
$('#querymessage').keypress(function(key) {
$('#messageError').fadeOut(500);
});
// $('#querycontact').keypress(function(key) {
// $('#contactError').fadeOut(500);
// if(key.charCode < 48 || key.charCode > 57) return false;
// else if($('#querycontact').val().length >= 10)
// {
// return false;
// }
// });
function loginFunction()
{
var rem="";
if($('#remember').is(":checked")){
rem="1";
}
else{
rem="0";
}
$.ajax({
type: 'POST',
url: 'pages/php/check.php',
data: { Username:$('#user').val(),Password:$('#pwd').val(),Remember:rem},
beforeSend: function() {
},
success: function(response) {
if(response.match(/confirm/))
{
window.open('pages/dashboard/dashboard.php','_self');
}
else{
$("#loginError").css('display','block');
}
}
});
}
function validateEmail($email) {
var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
return emailReg.test( $email );
}
function queryInput()
{
if($('#queryname').val()!='')
{
if($('#queryemail').val()!=''&&validateEmail($('#queryemail').val()))
{
if($('#querycontact').val()!=''&&$('#querycontact').val().length=='10')
{
if($('#querysubject').val()!='')
{
if($('#querymessage').val()!='')
{
$.ajax({
type: 'POST',
url: 'pages/php/addQuery.php',
data: { Name:$('#queryname').val(),Email:$('#queryemail').val(),Contact:$('#querycontact').val(),Subject:$('#querysubject').val(),Message:$('#querymessage').val()},
beforeSend: function() {
},
success: function(response) {
if(response.match(/success/))
{
alert('Query Successfully Placed');
}
else
{
alert('Not able to place your Query at the moment.Please try again later.Sorry for inconvinience');
}
}
});
}
else
{
$('#querymessage').focus();
$('#messageError').css('display','block');
}
}
else
{
$('#querysubject').focus();
$('#subjectError').css('display','block');
}
}
else
{
$('#querycontact').focus();
$('#contactError').css('display','block');
}
}
else
{
$('#queryemail').focus();
$('#emailError').css('visibility','visible');
$('#emailError').css('display','block');
}
}
else
{
$('#queryname').focus();
$('#emailError').css('display','block');
$('#emailError').css('visibility','hidden');
$('#nameError').css('display','block');
}
}