Entering the text box.

vdpramesh

Newcomer
Joined
Jan 15, 2004
Messages
3
Location
India
Hi,
I have one textbox and 2 aspx button on my form.
My requirement is , When i enter some value and press enter on the textbox, my page should be submitted without manually clicking on 2nd button.
The problem i am facing is, When i press the enter key, it is automatically fires the first click button click event. It should focus on 2nd button only.Even thought i specified tabindex correctly.
Can you solve this problem..

Thanks
Ramesh
 
Hi all,

you have to cancel the ENTER event and "click" the 2nd Button manually

Code:
<script language="javascript">
function jsKeyPress()
			{
				if (window.event.keycode == 13)
				{
					document.all["Button2"].click();
					return false;
				}
			}
</script>
<body onkeypress="return jsKeyPress();">

Regards, Stefan
 
if what u need is that ur enter key behaves as the tab then u need to do it using javascript, if u want only to move out of the textbox when pressing enter then also u should do it by javascript :)
anyways javascript is what u need....
 
Hi,
I have solved this issue. Here is the soln:

copy the script in aspx page.

<script language="JavaScript">
function setEnterKey(btnName) {
if (event.keyCode == 13) {
event.cancelBubble = true;
event.returnValue = false;
document.getElementById('btnsubmit1').click();
}
}
</script>

add the following handler in page load (vb file)

txtAccessCode.Attributes.Add("onkeypress", "setEnterKey('btnsubmit1');")

This works fine...

Regards
Ramesh
 
Back
Top