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