Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

signup.js 1010 B

You have to be logged in to leave a comment. Sign In
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
  1. const steps = Array.from(document.querySelectorAll("form .step"));
  2. const nextBtn = document.querySelectorAll("form .next-btn");
  3. const prevBtn = document.querySelectorAll("form .previous-btn");
  4. const form = document.querySelector("form");
  5. nextBtn.forEach((button) => {
  6. button.addEventListener("click", () => {
  7. changeStep("next");
  8. });
  9. });
  10. prevBtn.forEach((button) => {
  11. button.addEventListener("click", () => {
  12. changeStep("prev");
  13. });
  14. });
  15. form.addEventListener("submit", (e) => {
  16. e.preventDefault();
  17. const inputs = [];
  18. form.querySelectorAll("input").forEach((input) => {
  19. const { name, value } = input;
  20. inputs.push({ name, value });
  21. });
  22. console.log(inputs);
  23. form.reset();
  24. });
  25. function changeStep(btn) {
  26. let index = 0;
  27. const active = document.querySelector(".active");
  28. index = steps.indexOf(active);
  29. steps[index].classList.remove("active");
  30. if (btn === "next") {
  31. index++;
  32. } else if (btn === "prev") {
  33. index--;
  34. }
  35. steps[index].classList.add("active");
  36. }
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...