Posted by Ed Jay on 12/19/05 09:18
Adrienne Boswell <arbpen2003@sbcglobal.net> wrote:
>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.
Nope and yup. Just trying to circumvent the user from having to go back
and do the form because they inadvertently hit enter.
--
Ed Jay (remove M to respond by email)
[Back to original message]
|