|
@@ -198,6 +198,7 @@ class PasswordVerify extends Password {
|
|
|
let _repeatField = document.createElement('input')
|
|
|
let _successBtn = document.createElement('button')
|
|
|
|
|
|
+
|
|
|
let displayRepeat = () => {
|
|
|
if(this.getOpen() === false) {
|
|
|
_repeatField.style.marginTop = '10px'
|
|
@@ -271,6 +272,7 @@ function Form(el, data, okCallback, cancelCallback){
|
|
|
let formBody = document.createElement('div')
|
|
|
let okButton = document.createElement('button')
|
|
|
okButton.innerHTML = 'OK'
|
|
|
+ this.validators = {isValid:{}}
|
|
|
|
|
|
let cancelButton = document.createElement('button')
|
|
|
cancelButton.innerHTML = 'Cancel'
|
|
@@ -292,15 +294,13 @@ function Form(el, data, okCallback, cancelCallback){
|
|
|
el.appendChild(formBody)
|
|
|
|
|
|
|
|
|
- let checkInfo = (value, key, data, input, err) => {
|
|
|
- for(let key in this.validators) {
|
|
|
- if(key === 'isValid') continue;
|
|
|
- this.validators.isValid[key] = false
|
|
|
- }
|
|
|
- console.dir(this.validators)
|
|
|
+ this.checkInfo = (value, key, data, input, err) => {
|
|
|
let validCheck
|
|
|
let keyFormated = key
|
|
|
+ okButton.disabled = true
|
|
|
+
|
|
|
try {
|
|
|
+ console.log('valid', this.validators.isValid, data)
|
|
|
if(key[0] === "*") {
|
|
|
keyFormated = key.substring(1)
|
|
|
if(this.validators.mandatoryErr(value, key) === true) {
|
|
@@ -318,7 +318,7 @@ function Form(el, data, okCallback, cancelCallback){
|
|
|
} else {
|
|
|
validCheck = this.validators[keyFormated]? this.validators[keyFormated](value, keyFormated) : true
|
|
|
}
|
|
|
- console.log('validators ', this.validators)
|
|
|
+
|
|
|
if(typeof validCheck === 'string') {
|
|
|
input.style.backgroundColor = 'firebrick'
|
|
|
input.style.color = 'white'
|
|
@@ -332,15 +332,15 @@ function Form(el, data, okCallback, cancelCallback){
|
|
|
this.validators.isValid[key] = validCheck
|
|
|
}
|
|
|
|
|
|
- console.log(Object.keys(this.validators.isValid))
|
|
|
- console.log(Object.values(this.validators.isValid))
|
|
|
- console.log(Object.values(this.validators.isValid).every((item) => item === true))
|
|
|
+ console.log('valid', this.validators.isValid)
|
|
|
+
|
|
|
if(Object.values(this.validators.isValid).every((item) => item === true)) {
|
|
|
okButton.disabled = false
|
|
|
} else {
|
|
|
okButton.disabled = true
|
|
|
}
|
|
|
- } catch(e){console.warn('whoopsie', e)}
|
|
|
+
|
|
|
+ } catch(e){/*sample text*/}
|
|
|
}
|
|
|
|
|
|
let inputCreators = {
|
|
@@ -355,14 +355,14 @@ function Form(el, data, okCallback, cancelCallback){
|
|
|
let div = document.createElement('div')
|
|
|
input = new Password(div, true)
|
|
|
input.getHTMLElements().Password_input.value = ''
|
|
|
+ console.log('iz valid', this.validators.isValid)
|
|
|
+ this.validators.isValid[key] = false
|
|
|
wrap.append(input.getHTMLElements().Password_wrapper, small)
|
|
|
|
|
|
input.getHTMLElements().Password_input.oninput = (e) => {
|
|
|
func(input.getHTMLElements().Password_input.value)
|
|
|
- checkInfo(input.getHTMLElements().Password_input.value, key, {}, input.getHTMLElements().Password_input, small)
|
|
|
+ this.checkInfo(input.getHTMLElements().Password_input.value, key, {}, input.getHTMLElements().Password_input, small)
|
|
|
}
|
|
|
- func(input.getHTMLElements().Password_input.value)
|
|
|
- checkInfo(input.getHTMLElements().Password_input.value, key, {}, input.getHTMLElements().Password_input, small)
|
|
|
} else {
|
|
|
input = document.createElement('input')
|
|
|
input.type = 'text'
|
|
@@ -373,10 +373,8 @@ function Form(el, data, okCallback, cancelCallback){
|
|
|
|
|
|
input.oninput = () => {
|
|
|
func(input.value)
|
|
|
- checkInfo(input.value, key, {}, input, small)
|
|
|
+ this.checkInfo(input.value, key, {}, input, small)
|
|
|
}
|
|
|
- func(input.value)
|
|
|
- checkInfo(input.value, key, {}, input, small)
|
|
|
}
|
|
|
|
|
|
return wrap
|
|
@@ -398,10 +396,8 @@ function Form(el, data, okCallback, cancelCallback){
|
|
|
|
|
|
input.onchange = (e) => {
|
|
|
func(input.checked)
|
|
|
- checkInfo(input.checked, key, {}, input, small)
|
|
|
+ this.checkInfo(input.checked, key, {}, input, small)
|
|
|
}
|
|
|
- func(input.checked)
|
|
|
- checkInfo(input.checked, key, {}, input, small)
|
|
|
return wrap
|
|
|
},
|
|
|
|
|
@@ -422,10 +418,8 @@ function Form(el, data, okCallback, cancelCallback){
|
|
|
|
|
|
input.onchange = () => {
|
|
|
func(new Date(input.value))
|
|
|
- checkInfo(input.value, key, {}, input, small)
|
|
|
+ this.checkInfo(input.value, key, {}, input, small)
|
|
|
}
|
|
|
- func(new Date(input.value))
|
|
|
- checkInfo(input.value, key, {}, input, small)
|
|
|
return wrap
|
|
|
},
|
|
|
}
|
|
@@ -452,7 +446,6 @@ function Form(el, data, okCallback, cancelCallback){
|
|
|
this.cancelCallback = cancelCallback
|
|
|
|
|
|
this.data = data
|
|
|
- this.validators = {isValid:{}}
|
|
|
}
|
|
|
|
|
|
|
|
@@ -499,4 +492,9 @@ form.validators.birthday = (value, key, data, input) => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+for(let key in form) {
|
|
|
+ //проверка изначальных данных
|
|
|
+ form.checkInfo(form[key], key,)
|
|
|
+}
|
|
|
+
|
|
|
console.log(form)
|