diff --git a/app/static/js/csentry.js b/app/static/js/csentry.js new file mode 100644 index 0000000000000000000000000000000000000000..9bf4c7731f20d8a00b76ab40b1c81594c762a92c --- /dev/null +++ b/app/static/js/csentry.js @@ -0,0 +1,12 @@ +$(document).ready(function() { + + // When an invalid input was submitted, the server + // adds the "is-invalid" class to form fields to display + // them in red with an error message + // When starting to type again, we want to remove the error + // message to not confuse the user + $('input[type="text"]').keyup(function(event) { + $(this).removeClass("is-invalid"); + }); + +}); diff --git a/app/static/js/hosts.js b/app/static/js/hosts.js index c45f80d20f320b5b1a2915cbbe4b3812a38149d2..1a383042a7f9e34774d2c1e0771ea12f6aa4992a 100644 --- a/app/static/js/hosts.js +++ b/app/static/js/hosts.js @@ -71,6 +71,10 @@ $(document).ready(function() { $("#name").keyup(function(event) { var hostname = $(this).val(); $("#interface_name").val(hostname); + // If an invalid hostname was submitted, the interface name + // will be invalid as well + // Remove the invalid messages when starting typing a new name + $("#interface_name").removeClass("is-invalid"); }); // Fill MAC address on page load diff --git a/app/templates/base.html b/app/templates/base.html index d660cd4601a61955a12ea2c8f7dac6eb8c6ed290..0477e63ebbab6bb3a7cd9dddd202b3b7585549a7 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -65,5 +65,6 @@ <script type=text/javascript> $SCRIPT_ROOT = {{ request.script_root|tojson|safe }}; </script> + <script src="{{ url_for('static', filename='js/csentry.js') }}"></script> {% block csentry_scripts %}{% endblock %} {% endblock %}