-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
99 lines (80 loc) · 2.61 KB
/
script.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
var next_click=document.querySelectorAll(".next_button");
var main_form=document.querySelectorAll(".main");
var step_list = document.querySelectorAll(".progress-bar li");
var num = document.querySelector(".step-number");
let formnumber=0;
next_click.forEach(function(next_click_form){
next_click_form.addEventListener('click',function(){
if(!validateform()){
return false
}
formnumber++;
updateform();
progress_forward();
contentchange();
});
});
var back_click=document.querySelectorAll(".back_button");
back_click.forEach(function(back_click_form){
back_click_form.addEventListener('click',function(){
formnumber--;
updateform();
progress_backward();
contentchange();
});
});
var username=document.querySelector("#user_name");
var shownname=document.querySelector(".shown_name");
var submit_click=document.querySelectorAll(".submit_button");
submit_click.forEach(function(submit_click_form){
submit_click_form.addEventListener('click',function(){
shownname.innerHTML= username.value;
formnumber++;
updateform();
});
});
var heart=document.querySelector(".fa-heart");
heart.addEventListener('click',function(){
heart.classList.toggle('heart');
});
var share=document.querySelector(".fa-share-alt");
share.addEventListener('click',function(){
share.classList.toggle('share');
});
function updateform(){
main_form.forEach(function(mainform_number){
mainform_number.classList.remove('active');
})
main_form[formnumber].classList.add('active');
}
function progress_forward(){
num.innerHTML = formnumber+1;
step_list[formnumber].classList.add('active');
}
function progress_backward(){
var form_num = formnumber+1;
step_list[form_num].classList.remove('active');
num.innerHTML = form_num;
}
var step_num_content=document.querySelectorAll(".step-number-content");
function contentchange(){
step_num_content.forEach(function(content){
content.classList.remove('active');
content.classList.add('d-none');
});
step_num_content[formnumber].classList.add('active');
}
function validateform(){
validate=true;
var validate_inputs=document.querySelectorAll(".main.active input");
validate_inputs.forEach(function(vaildate_input){
vaildate_input.classList.remove('warning');
if(vaildate_input.hasAttribute('require')){
if(vaildate_input.value.length==0){
validate=false;
vaildate_input.classList.add('warning');
}
}
});
return validate;
}