Javascript
Been having a busy time with Javascript. Validating keypresses is much harder than it should be in browsers - why the W3C hasn't specc'ed full validation masks into HTML input fields is beyond me. I have been trying to make good user experience when entering fields. Most people validate at the end. I'd like to do it on the fly. Fine, I thought. I'll tap into onkeydown and throw out the events that don't matter.
Unfortunately it appears you cannot find the upshot of a certain keycombo. For instance if someone presses shift+3 they get a £ on UK keyboard or a # on US. I can find no good way of working out this before the event ends however. I have ended up firing onchange events to validate the field each time, and deleting the incorrectly entered items afterwards. This mostly works. But occasionally an event doesn't fire, and the whole thing comes crashing down. Finally I validate at the end of the form (since it may be wrong).
If anyone has seen a good way to solve this please shout.
Unfortunately it appears you cannot find the upshot of a certain keycombo. For instance if someone presses shift+3 they get a £ on UK keyboard or a # on US. I can find no good way of working out this before the event ends however. I have ended up firing onchange events to validate the field each time, and deleting the incorrectly entered items afterwards. This mostly works. But occasionally an event doesn't fire, and the whole thing comes crashing down. Finally I validate at the end of the form (since it may be wrong).
If anyone has seen a good way to solve this please shout.
Comments