-
Notifications
You must be signed in to change notification settings - Fork 1
/
verify.js
64 lines (53 loc) · 2.52 KB
/
verify.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
$(document).ready(function(){
$("#verify").click(function () {//wait for button click to happen
$("#errors").empty();
$("input[name='passwd2']").removeClass("red");
$("input[name='passwd']").removeClass("red");
$("input[name='name']").removeClass("red");
var name = $("input[name='name']");
var password = $("input[name='passwd']");
var password2 = $("input[name='passwd2']");//grabs the input object whos name is phone_number
var nameValue = name.val();
var passwordValue = password.val();//grabs value from the input object and puts it in phone_number
var passwordValue2 = password2.val();
var match = passwordValue.match(/(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,12}/i);
console.log(match + " : match value");
//variables to send to php
var postname = nameValue;
var postpass = passwordValue;
var availability = 0;
if(passwordValue == passwordValue2) {
$("input[name='passwd2']").removeClass("red");
$("input[name='passwd']").removeClass("red");
$("input[name='name']").removeClass("red");
if(match != null) {
//CHECK FOR USER NAME AVAILABILITY HERE
$.post('unameAvailability.php',{postname:nameValue},
function(data){
console.log(data + " : 0 if available, 1 if taken");
if(data == 0) {
//ADD DATA TO FILE HERE
$.post('validate.php',{postname:nameValue, postpass:passwordValue},
function(data){
});
window.location.assign("confirmPage.html")
}
else {
$("input[name='name']").addClass("red");
$("#errors").append("user name is already taken",'');
}
});
}
else {
$("input[name='passwd']").addClass("red");
$("input[name='passwd2']").addClass("red");
$("#errors").append("passwords must contain one lowercase letter, one upper case letter, one number, and be 8-12 chars",'');
}
}
else {
$("input[name='passwd']").removeClass("red");
$("input[name='passwd2']").addClass("red");
$("#errors").append("passwords are not the same",'');
}
});
});