gzieve
08-18-2005, 07:22 PM
I am trying to validate that a textbox is not empty using javascript.
The textbox id is txtstudycode.
Here is the codebehind code that responds to the submit link:
Private Sub lnksubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lnksubmit.Click
Dim strValidateStudyName As String = "<script language='JavaScript'>" & _
"{if document.getElementById('" + txtstudycode.Text + "') = '';" & _
"alert('Study Code is Required')}</script>"
If (Not Page.IsClientScriptBlockRegistered("validateStudyName")) Then
Page.RegisterClientScriptBlock("validateStudyName", strValidateStudyName)
End If
(some other stuff down here)
End Sub
I can't get it working. I'm not using the ASP validatation controls b/c there are other buttons on the page that I don't want the validation control to respond to. But if there's any easier way by using them, I'm open to that.
The textbox id is txtstudycode.
Here is the codebehind code that responds to the submit link:
Private Sub lnksubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lnksubmit.Click
Dim strValidateStudyName As String = "<script language='JavaScript'>" & _
"{if document.getElementById('" + txtstudycode.Text + "') = '';" & _
"alert('Study Code is Required')}</script>"
If (Not Page.IsClientScriptBlockRegistered("validateStudyName")) Then
Page.RegisterClientScriptBlock("validateStudyName", strValidateStudyName)
End If
(some other stuff down here)
End Sub
I can't get it working. I'm not using the ASP validatation controls b/c there are other buttons on the page that I don't want the validation control to respond to. But if there's any easier way by using them, I'm open to that.