diff --git a/packages/node_modules/@node-red/nodes/core/network/10-mqtt.html b/packages/node_modules/@node-red/nodes/core/network/10-mqtt.html index 0bb1e12f8..5b1b1f799 100644 --- a/packages/node_modules/@node-red/nodes/core/network/10-mqtt.html +++ b/packages/node_modules/@node-red/nodes/core/network/10-mqtt.html @@ -489,17 +489,23 @@ tls: {type:"tls-config",required: false, label:RED._("node-red:mqtt.label.use-tls") }, clientid: {value:"", validate: function(v, opt) { - var ok = false; + let ok = true; if ($("#node-config-input-clientid").length) { // Currently editing the node - ok = $("#node-config-input-cleansession").is(":checked") || (v||"").length > 0; + let needClientId = !$("#node-config-input-cleansession").is(":checked") || !$("#node-config-input-autoUnsubscribe").is(":checked") + if (needClientId) { + ok = (v||"").length > 0; + } } else { - ok = (this.cleansession===undefined || this.cleansession) || (v||"").length > 0; + let needClientId = !(this.cleansession===undefined || this.cleansession) || this.autoUnsubscribe; + if (needClientId) { + ok = (v||"").length > 0; + } } - if (ok) { - return ok; + if (!ok) { + return RED._("node-red:mqtt.errors.invalid-client-id"); } - return RED._("node-red:mqtt.errors.invalid-client-id"); + return true; }}, autoConnect: {value: true}, usetls: {value: false},