Skip to content

Instantly share code, notes, and snippets.

@sashabeep
Created September 19, 2023 10:06
Show Gist options
  • Save sashabeep/8f9f52182e34ec9ae71cb789268b4f2e to your computer and use it in GitHub Desktop.
Save sashabeep/8f9f52182e34ec9ae71cb789268b4f2e to your computer and use it in GitHub Desktop.
Masked input Evolution CMS
download https://raw.githubusercontent.com/digitalBush/jquery.maskedinput/master/dist/jquery.maskedinput.js
{
"elements": [
{
"label": "Elements",
"type": "text",
"value": "6,+7 (999) 999-9999",
"default": "6,+7 (999) 999-9999",
"desc": "TV ID,mask;..."
}
]
}
if($modx->event->name == 'OnDocFormRender') {
$elements = explode(";",trim($params['elements']));
$output = '<script src="/assets/plugins/maskedinput/js/maskedinput.js"></script>';
$output.= '<script>';
$output.='$(function(){';
foreach($elements as $k=>$elem){
$currEl = explode(",",$elem);
$el = $currEl[0];
$mask = $currEl[1];
$output.='$("[name=\'tv'.$el.'\']").mask("'.$mask.'");';
}
$output.='});';
$output.= '</script>';
$modx->event->output($output);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment