|
@@ -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,6 +294,7 @@ function Form(el, data, okCallback, cancelCallback){
|
|
|
el.appendChild(formBody)
|
|
|
|
|
|
|
|
|
+<<<<<<< HEAD
|
|
|
let checkInfo = (value, key, data, input, err) => {
|
|
|
console.log(this.initalData)
|
|
|
console.log(this.data)
|
|
@@ -300,9 +303,15 @@ function Form(el, data, okCallback, cancelCallback){
|
|
|
this.validators.isValid[key] = false
|
|
|
}
|
|
|
console.dir(this.validators)
|
|
|
+=======
|
|
|
+ this.checkInfo = (value, key, data, input, err) => {
|
|
|
+>>>>>>> 4a6ddce12df7d82608b2ab2f1082894f85ada9c2
|
|
|
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) {
|
|
@@ -320,7 +329,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'
|
|
@@ -334,15 +343,16 @@ 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)
|
|
|
+ } catch(e){/*sample text*/}
|
|
|
+
|
|
|
+ try {
|
|
|
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) {}
|
|
|
}
|
|
|
|
|
|
let inputCreators = {
|
|
@@ -357,14 +367,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'
|
|
@@ -375,12 +385,9 @@ 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
|
|
|
},
|
|
|
|
|
@@ -400,10 +407,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
|
|
|
},
|
|
|
|
|
@@ -424,10 +429,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
|
|
|
},
|
|
|
}
|
|
@@ -454,8 +457,11 @@ function Form(el, data, okCallback, cancelCallback){
|
|
|
this.cancelCallback = cancelCallback
|
|
|
|
|
|
this.data = data
|
|
|
+<<<<<<< HEAD
|
|
|
this.initalData = this.data
|
|
|
this.validators = {isValid:{}}
|
|
|
+=======
|
|
|
+>>>>>>> 4a6ddce12df7d82608b2ab2f1082894f85ada9c2
|
|
|
}
|
|
|
|
|
|
|
|
@@ -502,4 +508,9 @@ form.validators.birthday = (value, key, data, input) => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+for(let key in form) {
|
|
|
+ //проверка изначальных данных
|
|
|
+ form.checkInfo(form[key], key,)
|
|
|
+}
|
|
|
+
|
|
|
console.log(form)
|