diff --git a/public/assets/js/script.js b/public/assets/js/script.js index 3ae251c..dec5348 100644 --- a/public/assets/js/script.js +++ b/public/assets/js/script.js @@ -14,10 +14,19 @@ let deleteEvent = (v, message, url) => { }); }; -d.querySelectorAll('.js-group-btn-delete').forEach(v => { +d.querySelectorAll(".js-group-btn-delete").forEach(v => { deleteEvent(v, "You're sure to delete this group?", "/groups/delete") }); d.querySelectorAll(".js-server-btn-delete").forEach(v => { deleteEvent(v, "You're sure to delete this server?", "/servers/delete") +}); + +d.querySelector(".js-server-form-on-submit").addEventListener("submit", e=>{ + let check_ip = /^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/; + let ip = e.target.ip; + if (!check_ip.exec(ip.value)){ + e.preventDefault() + ip.focus() + } }); \ No newline at end of file diff --git a/src/templates/servers/add.tpl.php b/src/templates/servers/add.tpl.php index 9dceb76..fdf46f8 100644 --- a/src/templates/servers/add.tpl.php +++ b/src/templates/servers/add.tpl.php @@ -1,7 +1,7 @@ -