Click to See Complete Forum and Search --> : HTML Input boxes submit themselves???
benski
Oct 27th, 2000, 06:46 AM
I am confused by something that's happening with some asp pages I am editing.
I effectively just have a search box "frmSearch" and a button "btnSearch" which submits the form.
When I press {ENTER} in "frmSearch" the form is submitted. Why? How can I stop this happening?
Thanks!
dadames
Oct 27th, 2000, 07:34 AM
I think this is the default behavior for a form when you have a submit button. Perhaps, change the type to button and code an onClick event.
benski
Oct 27th, 2000, 07:37 AM
Yeah- I meant, when I press {ENTER} in the input box, not press the button.
The button is already a "button" not a "submit".
I have found a workaround for this behaviour though:
Check if they've pressed the {ENTER} key (keycode 13) then cancel the event if necessary.
sub frmSearch_onkeypress()
if document.theform.frmSearch.value = "" and window.event.keyCode = 13 then '{enter} key pressed with no data in input box
msgbox "You have not entered a search string!",0
window.event.returnValue = false
end if
if window.event.keyCode = 13 then
window.event.returnValue = false
end if
end sub
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.