libs/web: relax validation for hostnames to allow names like _kerberos._udp.EXAMPLE.COM
[project/luci.git] / libs / web / htdocs / luci-static / resources / cbi.js
index 655ddbf..d8719c4 100644 (file)
@@ -148,8 +148,8 @@ var cbi_validators = {
        'hostname': function()
        {
                if (this.length <= 253)
-                       return (this.match(/^[a-zA-Z]+$/) != null ||
-                               (this.match(/^[a-zA-Z0-9][a-zA-Z0-9\-.]*[a-zA-Z0-9]$/) &&
+                       return (this.match(/^[a-zA-Z0-9]+$/) != null ||
+                               (this.match(/^[a-zA-Z0-9_][a-zA-Z0-9_\-.]*[a-zA-Z0-9]$/) &&
                                 this.match(/[^0-9.]/)));
 
                return false;
@@ -441,7 +441,7 @@ function cbi_combobox(id, values, def, man) {
        var obj = document.getElementById(id)
        var sel = document.createElement("select");
                sel.id = selid;
-               sel.className = 'cbi-input-select';
+               sel.className = obj.className.replace(/cbi-input-text/, 'cbi-input-select');
 
        if (obj.nextSibling) {
                obj.parentNode.insertBefore(sel, obj.nextSibling);
@@ -504,6 +504,10 @@ function cbi_combobox(id, values, def, man) {
                        //Do nothing
                }
        })
+
+       // Retrigger validation in select
+       sel.focus();
+       sel.blur();
 }
 
 function cbi_combobox_init(id, values, def, man) {