diff options
author | Ivan Kohler <ivan-debian@420.am> | 2012-03-15 13:56:48 -0700 |
---|---|---|
committer | Ivan Kohler <ivan-debian@420.am> | 2012-03-15 13:56:48 -0700 |
commit | 7d68066ea33f9f85fe14ce663372642d7ec2ad20 (patch) | |
tree | f659173a23d541da3032f8a8156f888810d7efda /httemplate/elements/tr-input-mask.html | |
parent | d622dc369cc0856fb791658b35f889470a7da605 (diff) | |
parent | a69299c596de60f4b26db7431165f7f3ffe928e2 (diff) |
Merge branch 'master' of git.freeside.biz:/home/git/freeside
Diffstat (limited to 'httemplate/elements/tr-input-mask.html')
-rw-r--r-- | httemplate/elements/tr-input-mask.html | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/httemplate/elements/tr-input-mask.html b/httemplate/elements/tr-input-mask.html new file mode 100644 index 000000000..33725b9a5 --- /dev/null +++ b/httemplate/elements/tr-input-mask.html @@ -0,0 +1,41 @@ +% if ( !$init ) { +<script type="text/javascript" src="<%$p%>elements/masked_input_1.1.js"> +</script> +% $init++; +% } +<& /elements/tr-input-text.html, id => $id, @_ &> +<script type="text/javascript"> +MaskedInput({ + elm: document.getElementById('<%$id%>'), + format: '<% $opt{format} %>', + <% $opt{allowed} ? "allowed: '$opt{allowed}'," : '' %> + <% $opt{typeon} ? "typeon: '$opt{typeon}'," : '' %> +}); +document.getElementById('<%$id%>').value = <% $value |js_string %>; +</script> +<%shared> +my $init = 0; +</%shared> +<%init> +my %opt = @_; +# must have a DOM id +my $id = $opt{id} || sprintf('input%04d',int(rand(10000))); +my $value = length($opt{curr_value}) ? $opt{curr_value} : $opt{value} || ''; +</%init> +<%doc> +Set up a text input field with input masking. + +<& /elements/tr-input-mask.html, + format => '____-__-__', + #typeon => '_YMDhms', # which characters in the format represent blanks + #allowed => '0123456789', # characters allowed in the blanks + ... all other options as for tr-input-text.html +&> + +Note that the value sent on form submission will contain the mask +separators, and if value/curr_value is passed, it should also be +formatted to fit the mask. + +Uses masked_input_1.1.js by Kendall Conrad, available under a Creative Commons +Attribution-ShareAlike license. +</%doc> |