Created
September 19, 2023 10:06
-
-
Save sashabeep/8f9f52182e34ec9ae71cb789268b4f2e to your computer and use it in GitHub Desktop.
Masked input Evolution CMS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
download https://raw.githubusercontent.com/digitalBush/jquery.maskedinput/master/dist/jquery.maskedinput.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"elements": [ | |
{ | |
"label": "Elements", | |
"type": "text", | |
"value": "6,+7 (999) 999-9999", | |
"default": "6,+7 (999) 999-9999", | |
"desc": "TV ID,mask;..." | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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