P
Phil
Hi,
There is a form with two inputboxes and a submit button.The focus is on the
first inputbox.
When the user presses the enter-key without having entered some text, the
javascript message "wrong text" appears. This works.
But if i remove the second inputbox, leaving only the first inputbox and the
submit button, pressing the enter-key without any text does not show the
javascript message. Nothing happens. The focus remains in the inputbox. You
can see the page is postbacked, but that's all.
Why does it work with two inputboxes and not with one? And how to fix it?
Thanks
Phil
<body><form id="form1" runat="server">
<table>
<tr><td><input id="Text1" type="text" runat="server" /></td></tr>
<tr><td><input id="Text2" type="text" runat="server" /></td></tr>
<tr><td><input id="Submit1" type="submit" runat="server"
/></td></tr></table>
</form></body>
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Text1.Focus()
End Sub
Protected Sub Submit1_ServerClick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Submit1.ServerClick
Dim beh As String
beh = Text1.value
If beh = "xxx" Then
Response.Redirect("start.aspx", False)
Else
Page.ClientScript.RegisterClientScriptBlock(Me.GetType(),
"myscript", _
" alert('wrong text');", True)
End If
End Sub
There is a form with two inputboxes and a submit button.The focus is on the
first inputbox.
When the user presses the enter-key without having entered some text, the
javascript message "wrong text" appears. This works.
But if i remove the second inputbox, leaving only the first inputbox and the
submit button, pressing the enter-key without any text does not show the
javascript message. Nothing happens. The focus remains in the inputbox. You
can see the page is postbacked, but that's all.
Why does it work with two inputboxes and not with one? And how to fix it?
Thanks
Phil
<body><form id="form1" runat="server">
<table>
<tr><td><input id="Text1" type="text" runat="server" /></td></tr>
<tr><td><input id="Text2" type="text" runat="server" /></td></tr>
<tr><td><input id="Submit1" type="submit" runat="server"
/></td></tr></table>
</form></body>
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Text1.Focus()
End Sub
Protected Sub Submit1_ServerClick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Submit1.ServerClick
Dim beh As String
beh = Text1.value
If beh = "xxx" Then
Response.Redirect("start.aspx", False)
Else
Page.ClientScript.RegisterClientScriptBlock(Me.GetType(),
"myscript", _
" alert('wrong text');", True)
End If
End Sub