source: branches/1.2/workflow/js/jscalendar/calendar-input.js @ 1349

Revision 1349, 901 bytes checked in by niltonneto, 15 years ago (diff)

Ticket #561 - Inclusão do módulo Workflow faltante nessa versão.

  • Property svn:executable set to *
Line 
1function formatCalendarInput(campo, e)
2{
3        var key = '';
4        var valor = '';
5        var valorLimpo = '';
6        var len = 0;
7        var lenLimpo = 0;
8        var strCheck = '0123456789';
9
10        /* permite algumas teclas */
11        var whichCode = (e.which) ? e.which : e.keyCode;
12        if (whichCode == 13)
13                return true;  // Enter
14        if (whichCode == 8)
15                return true;  // Delete
16        if (whichCode == 0)
17                return true;  // Tab
18
19        key = String.fromCharCode(whichCode);
20        if (strCheck.indexOf(key) == -1)
21                return false;  // não é um caractere válido
22       
23        valor = campo.value;
24        len = valor.length;
25
26        for (var i = 0; i < len; i++)
27                if (strCheck.indexOf(valor.charAt(i)) != -1)
28                        valorLimpo += valor.charAt(i);
29       
30        valorLimpo += key;
31        lenLimpo = valorLimpo.length;
32        var valorNovo = '';
33        for (var i = 0; i < lenLimpo; i++)
34        {
35                valorNovo += valorLimpo.charAt(i);
36                if ((i == 1) || (i == 3))
37                        valorNovo += '/';
38        }
39
40        campo.value = valorNovo;
41        return false;
42}
Note: See TracBrowser for help on using the repository browser.