svc_hardware MAC address input format, #16266
[freeside.git] / httemplate / elements / tr-input-mask.html
1 % if ( !$init ) {
2 <script type="text/javascript" src="<%$p%>elements/masked_input_1.1.js">
3 </script>
4 % $init++;
5 % }
6 <& /elements/tr-input-text.html, id => $id, @_ &>
7 <script type="text/javascript">
8 MaskedInput({
9   elm: document.getElementById('<%$id%>'),
10   format: '<% $opt{format} %>',
11   <% $opt{allowed} ? "allowed: '$opt{allowed}'," : '' %>
12   <% $opt{typeon}  ? "typeon:  '$opt{typeon}',"  : '' %>
13 });
14 document.getElementById('<%$id%>').value = <% $value |js_string %>;
15 </script>
16 <%shared>
17 my $init = 0;
18 </%shared>
19 <%init>
20 my %opt = @_;
21 # must have a DOM id
22 my $id = $opt{id} || sprintf('input%04d',int(rand(10000)));
23 my $value = length($opt{curr_value}) ? $opt{curr_value} : $opt{value} || '';
24 </%init>
25 <%doc>
26 Set up a text input field with input masking.
27
28 <& /elements/tr-input-mask.html,
29   format    => '____-__-__',
30   #typeon   => '_YMDhms',    # which characters in the format represent blanks
31   #allowed  => '0123456789', # characters allowed in the blanks
32   ... all other options as for tr-input-text.html
33 &>
34
35 Note that the value sent on form submission will contain the mask 
36 separators, and if value/curr_value is passed, it should also be 
37 formatted to fit the mask.
38
39 Uses masked_input_1.1.js by Kendall Conrad, available under a Creative Commons
40 Attribution-ShareAlike license.
41 </%doc>