-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate.js
More file actions
46 lines (40 loc) · 2.1 KB
/
create.js
File metadata and controls
46 lines (40 loc) · 2.1 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
document.addEventListener('DOMContentLoaded', function() {
document.getElementById('loginForm').addEventListener('submit', function(event) {
// Previne comportamentul implicit de trimitere a formularului
event.preventDefault();
// Preia valoarea introdusă de utilizator din câmpul "Nume Complet"
const nume = document.getElementById('nume').value;
// Preia valoarea introdusă de utilizator din câmpul "Parola"
const parola = document.getElementById('parola').value;
const parola1=document.getElementById('parola1').value
//faci orice cu datele introduse de utilizator
fetch('user.json')
.then(response => response.json())
.then(jsonData => {
console.log(jsonData);
const userExists = jsonData.users.some(user => user.user === nume);
//Ma folosesc de local storage
if (userExists) {
alert("Acest cont mai exista aici ");
} else {
if(parola1===parola){
const newObject = { "user": nume, "parola": parola };
// Adaugă noul utilizator la array-ul existent de utilizatori
jsonData.users.push(newObject);
window.open('Comunitate.html', '_self');
}
else{
alert("Parola a fost introdusa de 2 ori gresit");
}
}
// Aici poți face orice dorești cu datele introduse de utilizator
console.log('Nume Complet:', nume);
console.log('Parola:', parola);
// Poți trimite datele către un server pentru verificare sau pentru a le procesa
// Exemplu: sendDataToServer(nume, parola);
})
.catch(error => {
console.error('Eroare la încărcarea JSON-ului:', error);
});
});
});