-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
87 lines (76 loc) · 2.23 KB
/
script.js
File metadata and controls
87 lines (76 loc) · 2.23 KB
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
var input_element = document.querySelectorAll('input');
// Loop even each DOM object
for (let i = 0; i < input_element.length; i++) {
input_element[i].addEventListener('keyup', (e) => {
input_element[i].setAttribute('value', input_element[i].value);
});
}
const sign_in_btn = document.querySelector('#sign-in-btn');
const sign_up_btn = document.querySelector('#sign-up-btn');
const container = document.querySelector('.container');
sign_up_btn.addEventListener('click', () => {
container.classList.add('sign-up-mode');
});
sign_in_btn.addEventListener('click', () => {
container.classList.remove('sign-up-mode');
});
// Here When User Login With his Account Then This funtion is Call.
function login() {
event.preventDefault();
let email = document.getElementById('username').value;
let password = document.getElementById('password').value;
firebase
.auth()
.signInWithEmailAndPassword(email, password)
.then((userCredential) => {
location.replace('welcome.html');
})
.catch((error) => {
var name = $('#username').val();
var password = $('#password').val();
if (name.length > 1 && password.length >= 8) {
Swal.fire({
position: 'center',
icon: 'error',
title: 'Opps! Email and Password not match.',
showConfirmButton: true,
timer: 3400,
});
}
});
}
// Here I Check The Input Feild If the Empty Click On the Button.
$('#submit').click(function () {
var name = $('#username').val();
var password = $('#password').val();
if (name == '') {
toastr.error('Please Enter Email Feild.');
} else if (password.length >= 1 && password.length < 8) {
toastr.warning('Your password is to short.');
} else if (password == '') {
toastr.error('Please Enter Password Feild.');
}
});
// Here I Validate The Input Feilds.
$('#sign-up-form').validate({
rules: {
email: {
required: true,
email: true,
},
password: {
required: true,
minlength: 8,
},
},
messages: {
email: {
required: '<p class="chip">Please enter a email address</p>',
email: '<p class="chip">Please enter a vaild email address</p>',
},
password: {
required: '<p class="chip">Please provide a password</p>',
minlength: '<p class="chip">Your password must be at least 8 characters long</p>',
},
},
});