C
Craig G
i have the following code for validating a textbox once a page posts, but
the problem i am having is that the TextChanged event won't fire next time
if the user does not change the value again
One way round this is to clear the value but user's generally like to see
the erroneous data
any ideas?
Cheers,
Craig
****************************************************************************
****
autocomplete needs to be turned off in the HTML for the form
<form id="Form1" method="post" runat="server" autocomplete="off">
****************************************************************************
****
Private Sub FirstNameTextBox_TextChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles FirstNameTextBox.TextChanged
If FirstNameTextBox.Text <> "Craig" Then
ASPNET_MsgBox("Incorrect value")
Set_Focus("FirstNameTextBox")
End If
End Sub
Public Sub ASPNET_MsgBox(ByVal Message As String)
System.Web.HttpContext.Current.Response.Write("<SCRIPT
LANGUAGE=""JavaScript"">" & vbCrLf)
System.Web.HttpContext.Current.Response.Write("alert(""" & Message & """)" &
vbCrLf)
System.Web.HttpContext.Current.Response.Write("</SCRIPT>")
End Sub
Sub Set_Focus(ByVal strControlName)
Dim strScript As String
strScript = "<script language=javascript> document.all(""" & strControlName
& """).focus() </script>"
RegisterStartupScript("focus", strScript)
End Sub
the problem i am having is that the TextChanged event won't fire next time
if the user does not change the value again
One way round this is to clear the value but user's generally like to see
the erroneous data
any ideas?
Cheers,
Craig
****************************************************************************
****
autocomplete needs to be turned off in the HTML for the form
<form id="Form1" method="post" runat="server" autocomplete="off">
****************************************************************************
****
Private Sub FirstNameTextBox_TextChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles FirstNameTextBox.TextChanged
If FirstNameTextBox.Text <> "Craig" Then
ASPNET_MsgBox("Incorrect value")
Set_Focus("FirstNameTextBox")
End If
End Sub
Public Sub ASPNET_MsgBox(ByVal Message As String)
System.Web.HttpContext.Current.Response.Write("<SCRIPT
LANGUAGE=""JavaScript"">" & vbCrLf)
System.Web.HttpContext.Current.Response.Write("alert(""" & Message & """)" &
vbCrLf)
System.Web.HttpContext.Current.Response.Write("</SCRIPT>")
End Sub
Sub Set_Focus(ByVal strControlName)
Dim strScript As String
strScript = "<script language=javascript> document.all(""" & strControlName
& """).focus() </script>"
RegisterStartupScript("focus", strScript)
End Sub