Front End Form verify values
1834423612 opened this issue · comments
Fix: Form verify those values(Required or not) => Submit
【Vue-dev】(Front-End)
Pit-scouting/src/components/form.vue
Lines 255 to 309 in c5e6554
watch: { | |
robotWeight(newValue,oldValue){ | |
if (!newValue.test('^\d+(\s\d+\/\d+)?(\.\d+)?$|^\d+\/\d+$')){ | |
//change back to old value | |
//make seperate validation | |
//prevent storage from storing the newValue | |
} | |
}, | |
robotDimensionLength(newValue,oldValue){}, | |
robotDimensionWidth(newValue,oldValue){}, | |
robotDimensionHeight(newValue,oldValue){}, | |
heightWhenFullyExtended(newValue,oldValue){}, | |
practiceHoursPerWeek(newValue,oldValue){}, | |
form: { | |
handler(newForm) { | |
this.formModified = true; // Form has been modified | |
if (this.saveTimeout) { | |
clearTimeout(this.saveTimeout); | |
} | |
this.saveTimeout = setTimeout(() => { | |
this.savingStatus = 'saving'; | |
let arr = window.localStorage.getItem('TabsArray') | |
let TabsArray = JSON.parse(arr) | |
TabsArray.map(item => { | |
if (item.name == this.tabIndex) { | |
item.formValue = newForm | |
} | |
}) | |
window.localStorage.setItem('TabsArray', JSON.stringify(TabsArray)) | |
//Object.keys(this.valid).forEach((item,index)=>{ | |
// this.valid.item.entered= | |
//}) | |
// | |
//newForm.forEach((question) => { | |
// if (question.type === "checkbox") { | |
// localStorage.setItem( | |
// question.question, | |
// JSON.stringify(question.value) | |
// ); | |
// } else { localStorage.setItem(question.question, question.value); } | |
// localStorage.setItem( | |
// question.question + "-otherValue", | |
// question.otherValue | |
// ); | |
// }); | |
setTimeout(() => { | |
this.savingStatus = 'success'; | |
this.formModified = false; // Reset the form status | |
}, 1400); // Set the saving status TEXT to success after 1.4 seconds | |
}, 300); // Save the form data after 0.3 seconds | |
}, | |
deep: true, | |
}, |
Now solution:
Create a newValue and compare new&old