-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreg.js
96 lines (92 loc) · 2.43 KB
/
reg.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
$(document).ready(function(){
//
//var valid = function (login,password,re_password,email) {
//
//}
$("#myform").submit(function(e) {
e.preventDefault();
});
$("#submit-form").click(function(){
var login= $("#login").val();
var password= $("#password").val();
var re_password= $("#re_password").val();
var email= $("#email").val();
var errors = new Array();
var error = 1;
var error_login='';
var error_pass='';
var bu = '';
if (login.length < 1 ) {
errors.push('not entered login');
error = 2;
} else{
$.ajax({
type: 'POST',
async: false,
url: 'validation/reg_login.php',
data: 'login='+login,
success: function(res){
if (res.indexOf('user_with_thant_name_exist')>-1) {
// $('.login').append("<span class="error">Erorr</span>");
errors.push('user witht hant login exist');
error = 2;
}
}
});
}
if (password.length < 1 ) {
errors.push('not entered password');
error = 2;
}
if (re_password.length < 1 ) {
errors.push('not entered re_password');
error = 2;
}
if (password !== re_password) {
error = 2;
errors.push('password and Repassword');
}
//var regexp = "/[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/";
var r = /^\w+@\w+\.\w{2,4}$/i;
//if (!r.test(email)
//var regexp = "/^[a-zA-Z0-9_\-.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-.]+$/";
//var pos = email.search(regexp);
if (email.length <1 || !r.test(email)) {
errors.push('wrong email');
error = 2;
}else{
//alert("sad");
$.ajax({
type: 'POST',
async: false,
url: 'validation/reg_email.php',
data: 'email='+email,
success: function(res){
if (res.indexOf('user_with_thant_email_exist')>-1) {
// $('.login').append("<span class="error">Erorr</span>");
errors.push('user with thant email exist');
error = 2;
}
}
});
}
//alert(error);
if (error == 1) {
$.ajax({
type: 'POST',
async: false,
url: 'reg_js.php',
data: {
login: login,
email: email,
password: password,
},
success: function(res){
document.location.href = 'index.php';
}
});
}else{
alert( errors);
}
});
});