Parcourir la source

сделал рабочей кнопку при вводе инпутов

kurkabein il y a 2 ans
Parent
commit
5b57a666d5
1 fichiers modifiés avec 17 ajouts et 4 suppressions
  1. 17 4
      password_OOP/main.js

+ 17 - 4
password_OOP/main.js

@@ -94,7 +94,12 @@ function Form (parent){
     /* pswd.setValue('qwerty'); */
 
     let actionbutton = (passwordValue) => {
-        (passwordValue && this.getloginValue())? acceptButton.disabled = false : acceptButton.disabled=true        
+       /*  (passwordValue && this.getloginValue())? acceptButton.disabled = false : acceptButton.disabled=true */
+       if(passwordValue && this.getloginValue()){
+           acceptButton.disabled = false
+       }else {
+           acceptButton.disabled = true
+       }
     }
     this.setLoginValue = value =>{
         loginValue = value;
@@ -113,10 +118,15 @@ function Form (parent){
         this.setLoginValue(login.value);
     }
 
-   this.setValuePassword = (newpswd) => {
-       pswd.setValue(newpswd)
+
+    pswd.onChange = (newpswd) => {
+        if(newpswd !== pswd.getValue() && typeof this.onChangePswd ==='function'){
+                this.onChangePswd(newpswd);
+        }
         actionbutton(pswd.getValue());
     }
+
+
     /* let pswdTrueOrNot = (passwordValue, checkPswdValue) =>{
         if(checkPswdValue !== passwordValue){
             checkPswd.style.border = 'red'
@@ -139,7 +149,10 @@ function Form (parent){
     } */
     // trash set and get
     this.getValuePassword = () => pswd.getValue();
-    actionbutton(this.getValuePassword());
+    this.setValuePassword = (newpswd) => {
+        pswd.setValue(newpswd);
+     }
+    actionbutton(pswd.getValue());
 }
 
  /* let p = new Password(document.body, true); */