Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #12511
| Newsgroups | comp.lang.javascript |
|---|---|
| Subject | Re: Fancy Date Entry |
| From | "Evertjan." <exjxw.hannivoort@interxnl.net> |
| References | <2n7gl7pfgu7mni1bj6cvluit67cnve4ge8@4ax.com> |
| Message-ID | <XnsA0113FAEA48Feejj99@194.109.133.133> (permalink) |
| Date | 2012-03-08 23:23 +0000 |
Gene Wirchenko wrote on 08 mrt 2012 in comp.lang.javascript:
> In the example below "[" and "]" are the field delimiters and "^"
> is the cursor. What I would like to be able to do is:
>
> Initialise field:
> [20120307^]
> Enter "1":
> [20120301^]
> Enter "0":
> [20120310^]
> Enter "2":
> [20120102^]
> Enter "5":
> [20121025^]
> Enter <tab>:
> Entered date is 2012-10-25.
>
I think it is a silly way to enter a date,
but the programming is simple for someone
with an extensive experience in c++, etc.
A minimalistic example,
without your tab function,
automatic focus is here the body,
[chrome and ie tested]:
==========================
<body onkeyup='getKey(event)'>
[<span id=a>20120307</span><span
id=b style='color:red;'></span>]
<br><br>re-initialize by pressing 'i'.
<script type='text/javascript'>
var s = '';
function getKey(e) {
var charCode = (e.which) ? e.which : e.keyCode
if (charCode==73) s = '';
if (charCode>47 && charCode<58) s += charCode-48;
if (charCode>95 && charCode<106) s += charCode-96;
if (s.length<9) {
document.getElementById('a').innerHTML =
'20120307'.substr(0,8-s.length);
document.getElementById('b').innerHTML = s;
};
};
</script>
==========================
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Fancy Date Entry Gene Wirchenko <genew@ocis.net> - 2012-03-07 19:02 -0800
Re: Fancy Date Entry "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-03-08 23:23 +0000
Re: Fancy Date Entry Gene Wirchenko <genew@ocis.net> - 2012-03-08 19:32 -0800
Re: Fancy Date Entry "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-03-09 08:09 +0000
Re: Fancy Date Entry Dr J R Stockton <reply1210@merlyn.demon.co.uk> - 2012-03-09 21:18 +0000
csiph-web