Posted by Adrienne Boswell on 12/19/05 02:29
Gazing into my crystal ball I observed Ed Jay <edMbj@aes-intl.com> writing
in news:pv6bq159lmmdfighhsusqqf083gelrec6c@4ax.com:
> My form consists of text boxes, radio buttons and checkboxes. I use the
> following js to trap(kill) the enter key during text box entry to prevent
> inadvertent form submission:
>
> var keys = document.all?true:false;
> function keyHandler(e) {
> var _ret=true;
> var _char=keys?event.keyCode:e.which;
> if(_char==13)
> _ret=false;
> return _ret;
> }
>
> I call it from within textbox form elements as
><input name="X" type="text" onkeypress="return keyHandler();">
>
> This works fine as long as the focus is on a text box. OTOH, if I've
> clicked a radio button or checkbox and then press 'Return (keycode 13)'
> the form is submitted.
>
> How do I globally protect against such inadvertency?
>
I hope you are not relying on javascript to do all the validation. Make
sure you validate on the server as well.
--
Adrienne Boswell
http://www.cavalcade-of-coding.info
Please respond to the group so others can share
Navigation:
[Reply to this message]
|