Control MAC address entry

Warning and refocus if not conform to indicated requirements
This commit is contained in:
steve-lad 2021-06-18 16:50:15 +02:00
parent 510b4259ac
commit d6cfa86978
3 changed files with 19 additions and 1 deletions

View file

@ -212,6 +212,15 @@ $(document).ready(function () {
e.preventDefault(); e.preventDefault();
}); });
$('#sccp_hw_mac').change(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 ) {
fpbxToast(_('Invalid Mac Address'),_('Invalid Mac Address'), 'warning');
setTimeout(function(){document.getElementById("sccp_hw_mac").focus();},2000);
};
});
// Form.buttons - Form.adddevice // Form.buttons - Form.adddevice
$('.futuretype').change(function (e) { $('.futuretype').change(function (e) {
var kid = $(this).data('id'); var kid = $(this).data('id');

View file

@ -35,6 +35,9 @@ trait ajaxHelper {
case 'delete_dialplan': case 'delete_dialplan':
return true; return true;
break; break;
case 'validateMac':
return true;
break;
default: default:
return false; return false;
} }
@ -49,6 +52,8 @@ trait ajaxHelper {
case 'savesettings': case 'savesettings':
// Consolidate this into a separate method to improve legibility // Consolidate this into a separate method to improve legibility
$this->handleSubmit($request); $this->handleSubmit($request);
// TODO: Need to be more specific on reload and only reload if critical settings changed.
$res = $this->aminterface->core_sccp_reload(); $res = $this->aminterface->core_sccp_reload();
$msg [] = array ("Config Saved: {$res['Response']}", "Info : {$res['data']}"); $msg [] = array ("Config Saved: {$res['Response']}", "Info : {$res['data']}");
@ -376,6 +381,9 @@ trait ajaxHelper {
// return array('status' => false, 'message' => $result); // return array('status' => false, 'message' => $result);
return $result; return $result;
break; break;
case 'validateMac':
dbug('Request', $_REQUEST);
break;
} }
} }

View file

@ -115,6 +115,7 @@ trait bmoFunctions {
); );
break; break;
case 'sccpsettings': case 'sccpsettings':
// TODO: Need to change to have save and save and continue
$buttons = array( $buttons = array(
'submit' => array( 'submit' => array(
'name' => 'ajaxsubmit', 'name' => 'ajaxsubmit',