-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
58 lines (49 loc) · 1.58 KB
/
main.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
let name, age, city, profession, gender, checkedGender, $showData, $buttonSubmit, $form, $buttonReset
// class new user
class NewUser{
handleGetNewUser(){
name= document.querySelector('#name').value
age = document.querySelector('#age').value
city = document.querySelector('#city').value
profession= document.querySelector('#profession').value
gender = document.querySelectorAll("input[name='gender']")
this.checkedValueGender(gender)
this.showDataUI(name, age, city, profession, checkedGender)
}
checkedValueGender(gender){
gender.forEach((genders, i, gender )=>{
let genderCheckedValue = genders.checked
genderCheckedValue? checkedGender= gender[i].value : null
})
}
validateDate(){
}
showDataUI(name, age, city, profession,checkedGender){
$showData = document.getElementById("texto");
$showData.innerHTML = `Hola soy un ${checkedGender}, y mi nombre es ${this.capitalLetter(name)}. Tengo ${age} años. Soy ${profession}, y vivo en ${this.capitalLetter(city)}.` ;
}
resetForm(){
$form = document.querySelector('form')
$form.reset()
}
capitalLetter(string){
return string.charAt(0).toUpperCase() + string.slice(1);
}
}
function inicio()
{
const user = new NewUser
$buttonSubmit = document.querySelector("#buttonEnviar");
$buttonSubmit.addEventListener("click", app);
$buttonReset = document.querySelector('#buttonReset')
$buttonReset.addEventListener("click", user.resetForm)
};
function app()
{
$('#modal').on('shown.bs.modal', function () {
$('#ModalInput').trigger('focus')
})
const user = new NewUser
user.handleGetNewUser()
user.resetForm()
}