luci-base: prevent empty field for adding new named section in JavaScript
Suggested-by: Helge Mader <ma@dev.tdt.de> Signed-off-by: Florian Eckert <fe@dev.tdt.de>
This commit is contained in:
parent
80262bb9a7
commit
87215e3d1b
1 changed files with 12 additions and 2 deletions
|
@ -2212,11 +2212,21 @@ var CBITypedSection = CBIAbstractSection.extend(/** @lends LuCI.form.TypedSectio
|
||||||
|
|
||||||
return this.handleAdd(ev, nameEl.value);
|
return this.handleAdd(ev, nameEl.value);
|
||||||
}),
|
}),
|
||||||
'disabled': this.map.readonly || null
|
'disabled': true
|
||||||
}, [ btn_title || _('Add') ])
|
}, [ btn_title || _('Add') ])
|
||||||
]);
|
]);
|
||||||
|
|
||||||
ui.addValidator(nameEl, 'uciname', true, 'blur', 'keyup');
|
ui.addValidator(nameEl, 'uciname', true, function(v) {
|
||||||
|
var button = document.querySelector('.cbi-section-create > .cbi-button-add');
|
||||||
|
if (v !== '') {
|
||||||
|
button.disabled = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
button.disabled = true;
|
||||||
|
return _('Expecting: %s').format(_('non-empty value'));
|
||||||
|
}
|
||||||
|
}, 'blur', 'keyup');
|
||||||
}
|
}
|
||||||
|
|
||||||
return createEl;
|
return createEl;
|
||||||
|
|
Loading…
Reference in a new issue