From 6cf55da3755d86784aa79998e2e2ed90b6489611 Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Fri, 6 Jul 2018 13:12:53 +0300 Subject: [PATCH] Don't show alert on already set hostname --- code/html/custom.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/code/html/custom.js b/code/html/custom.js index 71e1e04e..7d4a3586 100644 --- a/code/html/custom.js +++ b/code/html/custom.js @@ -176,8 +176,13 @@ function validateForm(form) { var re_hostname = new RegExp('^(?!-)[A-Za-z0-9-]{0,31}[A-Za-z0-9]$'); - var hostname = $("input[name='hostname']", form).val(); - if (!re_hostname.test(hostname)) { + var hostname = $("input[name='hostname']", form); + var hasChanged = hostname.attr("hasChanged") || 0; + if (0 === hasChanged) { + return true; + } + + if (!re_hostname.test(hostname.val())) { alert("Hostname cannot be empty and may only contain the ASCII letters ('A' through 'Z' and 'a' through 'z'), the digits '0' through '9', and the hyphen ('-')! They can neither start or end with an hyphen."); return false; }