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();
});
$('#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
$('.futuretype').change(function (e) {
var kid = $(this).data('id');

View file

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

View file

@ -32,7 +32,7 @@ trait bmoFunctions {
Below adds redirect URL, but it is not followed
$cc->setRedirectURL("config.php?display=sccp_phone");
so force redirect at end of addDevice in SccpClass
*/
*/
}
}
}
@ -115,6 +115,7 @@ trait bmoFunctions {
);
break;
case 'sccpsettings':
// TODO: Need to change to have save and save and continue
$buttons = array(
'submit' => array(
'name' => 'ajaxsubmit',