|
@@ -41,7 +41,7 @@ function Password2(parent, open = false) {
|
|
|
let password = document.createElement("input");
|
|
|
parent.append(password);
|
|
|
password.setAttribute("type", open ? "text" : "password");
|
|
|
- password.setAttribute("placeholder", "Password");
|
|
|
+ password.setAttribute("placeholder", "Password");
|
|
|
|
|
|
let showPassword = document.createElement("input");
|
|
|
parent.append(showPassword);
|
|
@@ -50,7 +50,7 @@ function Password2(parent, open = false) {
|
|
|
let login = document.createElement("input");
|
|
|
parent.append(login);
|
|
|
login.setAttribute("type", "text");
|
|
|
- login.setAttribute("placeholder", "Login");
|
|
|
+ login.setAttribute("placeholder", "Login");
|
|
|
|
|
|
let loginButton = document.createElement("button");
|
|
|
parent.append(loginButton);
|
|
@@ -63,8 +63,16 @@ function Password2(parent, open = false) {
|
|
|
password.setAttribute("type", showPassword.checked ? "text" : "password");
|
|
|
}
|
|
|
|
|
|
- password.oninput = () => {
|
|
|
- this.onChange(password.value);
|
|
|
+ password.oninput = login.oninput = () => {
|
|
|
+ this.onChange({
|
|
|
+ password: password.value,
|
|
|
+ login: login.value
|
|
|
+ });
|
|
|
+ if (password.value && login.value) {
|
|
|
+ loginButton.disabled = false;
|
|
|
+ } else {
|
|
|
+ loginButton.disabled = true;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
this.onChange = () => {};
|
|
@@ -73,13 +81,103 @@ function Password2(parent, open = false) {
|
|
|
password.value = someVal;
|
|
|
}
|
|
|
|
|
|
- this.getPassword = function () {
|
|
|
- return password.value;
|
|
|
+ // this.getPassword = function () {
|
|
|
+ // return password.value;
|
|
|
+ // }
|
|
|
+
|
|
|
+ this.getter = function () {
|
|
|
+ return {
|
|
|
+ password: password.value,
|
|
|
+ login: login.value,
|
|
|
+ check: showPassword.checked
|
|
|
+ };
|
|
|
}
|
|
|
|
|
|
- // if(password.value && login.value) {
|
|
|
- // loginButton.disabled = falce;
|
|
|
- // }
|
|
|
+ this.setLogin = function (someVal) {
|
|
|
+ login.value = someVal;
|
|
|
+ }
|
|
|
+
|
|
|
+ this.setCheckbox = function (someVal) {
|
|
|
+ showPassword.checked = someVal;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+let form2 = new Password2(task2, false);
|
|
|
+form2.onChange = (x) => console.log(x);
|
|
|
+
|
|
|
+//-------------------------------------------------------Password Verify--------------------------------------------------------------------
|
|
|
+
|
|
|
+function Password3(parent, open = false) {
|
|
|
+ let login = document.createElement("input");
|
|
|
+ parent.append(login);
|
|
|
+ login.setAttribute("type", "text");
|
|
|
+ login.setAttribute("placeholder", "Login");
|
|
|
+
|
|
|
+ let password = document.createElement("input");
|
|
|
+ parent.append(password);
|
|
|
+ password.setAttribute("type", open ? "text" : "password");
|
|
|
+ password.setAttribute("placeholder", "Password");
|
|
|
+
|
|
|
+ let confirmPassword = document.createElement("input");
|
|
|
+ parent.append(confirmPassword);
|
|
|
+ confirmPassword.setAttribute("type", "password");
|
|
|
+ confirmPassword.setAttribute("placeholder", "Confirm Password");
|
|
|
+
|
|
|
+ let showPassword = document.createElement("input");
|
|
|
+ parent.append(showPassword);
|
|
|
+ showPassword.setAttribute("type", "checkbox");
|
|
|
+
|
|
|
+ let loginButton = document.createElement("button");
|
|
|
+ parent.append(loginButton);
|
|
|
+ loginButton.innerText = "__OK__";
|
|
|
+ loginButton.disabled = true;
|
|
|
+
|
|
|
+ showPassword.checked = open;
|
|
|
+
|
|
|
+ showPassword.onclick = () => {
|
|
|
+ password.setAttribute("type", showPassword.checked ? "text" : "password");
|
|
|
+ if (showPassword.checked) {
|
|
|
+ confirmPassword.style.display = "none";
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ confirmPassword.style.display = "block";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ password.oninput = login.oninput = confirmPassword.oninput = () => {
|
|
|
+ this.onChange({
|
|
|
+ password: password.value,
|
|
|
+ login: login.value,
|
|
|
+ confirmPassword: confirmPassword.value
|
|
|
+ });
|
|
|
+ if (password.value && login.value && confirmPassword.value) {
|
|
|
+ loginButton.disabled = false;
|
|
|
+ } else {
|
|
|
+ loginButton.disabled = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ this.onChange = () => {};
|
|
|
+
|
|
|
+ this.setPassword = function (someVal) {
|
|
|
+ password.value = someVal;
|
|
|
+ }
|
|
|
+
|
|
|
+ this.getter = function () {
|
|
|
+ return {
|
|
|
+ password: password.value,
|
|
|
+ login: login.value,
|
|
|
+ check: showPassword.checked
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
+ this.setLogin = function (someVal) {
|
|
|
+ login.value = someVal;
|
|
|
+ }
|
|
|
+
|
|
|
+ this.setCheckbox = function (someVal) {
|
|
|
+ showPassword.checked = someVal;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-let form2 = new Password2(task2, true);
|
|
|
+let form3 = new Password3(task3, false);
|