fix: add validation to input fields
This commit is contained in:
parent
2413a2654f
commit
48f2ff9cc1
1 changed files with 8 additions and 2 deletions
10
sq2bs.js
10
sq2bs.js
|
@ -5,7 +5,7 @@ let skp_keys = ['str', 'dex', 'int', 'def', 'agi'];
|
|||
document.addEventListener('DOMContentLoaded', function() {
|
||||
|
||||
for (const i in equipment_keys) {
|
||||
document.querySelector("#"+equipment_keys[i]+"-choice").setAttribute("oninput", "update_fields('"+equipment_keys[i]+"'); calcBuildSchedule()");
|
||||
document.querySelector("#"+equipment_keys[i]+"-choice").setAttribute("oninput", "calcBuildSchedule()");
|
||||
document.querySelector("#"+equipment_keys[i]+"-powder").setAttribute("oninput", "calcBuildSchedule()");
|
||||
}
|
||||
document.querySelector("#level-choice").setAttribute("oninput", "calcBuildSchedule()")
|
||||
|
@ -59,9 +59,15 @@ function update_fields() {
|
|||
|
||||
// resets
|
||||
document.querySelector("#"+equipment_keys[i]+"-choice").classList.remove("text-light", "is-invalid", 'Normal', 'Unique', 'Rare', 'Legendary', 'Fabled', 'Mythic', 'Set');
|
||||
|
||||
console.log(document.querySelector("#"+equipment_keys[i]+"-choice").value)
|
||||
let item = player_build[equipment_keys[i]];
|
||||
|
||||
if ((item.get('name') == 'No '+ equipment_keys[i].charAt(0).toUpperCase() + equipment_keys[i].slice(1)) && (document.querySelector("#"+equipment_keys[i]+"-choice").value)) {
|
||||
document.querySelector("#"+equipment_keys[i]+"-choice").classList.add("text-light", "is-invalid");
|
||||
document.querySelector("#"+equipment_keys[i]+"-powder").disabled = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
// set input text color
|
||||
document.querySelector("#"+equipment_keys[i]+"-choice").classList.add(item.get('tier'));
|
||||
|
||||
|
|
Loading…
Reference in a new issue