From 1f910c7e97611104a71e22d7ad5e09c32b035428 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Thu, 29 Jul 2021 15:40:23 +0200 Subject: [PATCH] Force entry of correct mac address before save is enabled Move focus to Mac field and stay until a correct Mac address is entered, disabling Save buttons until correct Motive: a device record with an empty Mac address requires manual removal. --- assets/js/sccp_manager.js | 11 +++++++++-- conf/sccpgeneral.xml.v433 | 5 +++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/assets/js/sccp_manager.js b/assets/js/sccp_manager.js index 6c3b326..1fffeb4 100644 --- a/assets/js/sccp_manager.js +++ b/assets/js/sccp_manager.js @@ -214,12 +214,19 @@ $(document).ready(function () { e.preventDefault(); }); - $('#sccp_hw_mac').change(function() { + $('#sccp_hw_mac').focus(); + + $('#sccp_hw_mac').focusout(function() { var value = $(this).val(); const regex = new RegExp('^([0-9A-Fa-f]{2}[:.-]?){5}([0-9A-Fa-f]{2})$'); if ( regex.test(value) === false ) { + $('#ajaxsubmit2').attr('disabled', 'disabled'); + $('#ajaxsubmit').attr('disabled', 'disabled'); fpbxToast(_('Invalid Mac Address'),_('Invalid Mac Address'), 'warning'); - setTimeout(function(){document.getElementById("sccp_hw_mac").focus();},2000); + setTimeout(function(){ $('#sccp_hw_mac').focus();},2000); + } else { + $('#ajaxsubmit2').removeAttr('disabled'); + $('#ajaxsubmit').removeAttr('disabled'); }; }); diff --git a/conf/sccpgeneral.xml.v433 b/conf/sccpgeneral.xml.v433 index 48e3d92..47522ad 100644 --- a/conf/sccpgeneral.xml.v433 +++ b/conf/sccpgeneral.xml.v433 @@ -1253,8 +1253,9 @@ and open the template in the editor. Base Version before all crash :-) mac - 000000000 + sccp-custom + The MAC address of the phone. You must specify 12 characters in the format XXXX.XXXX.XXXX or XX-XX-XX-XX-XX-XX or XXXXXXXXXXXX @@ -1282,7 +1283,7 @@ and open the template in the editor. Base Version before all crash :-) mac - 000000000 + sccp-custom