luci-base: cbi.js: recognize invalid input in dropdown create field
authorJo-Philipp Wich <jo@mein.io>
Wed, 10 Oct 2018 06:28:15 +0000 (08:28 +0200)
committerJo-Philipp Wich <jo@mein.io>
Wed, 10 Oct 2018 06:29:02 +0000 (08:29 +0200)
This is required to allow for validating the create field values in
later commits.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
modules/luci-base/htdocs/luci-static/resources/cbi.js

index fcfc5069426685da91362906040a31533765f8e7..e5acdbcd79d101ea8f18782731d39612ab213127 100644 (file)
@@ -2062,8 +2062,12 @@ function cbi_dropdown_init(sb) {
                create.addEventListener('keydown', function(ev) {
                        switch (ev.keyCode) {
                        case 13:
-                               sbox.createItems(sb, this.value);
                                ev.preventDefault();
+
+                               if (this.classList.contains('cbi-input-invalid'))
+                                       return;
+
+                               sbox.createItems(sb, this.value);
                                this.value = '';
                                this.blur();
                                break;