You must Sign In to post a response.
  • Category: ASP.NET

    Textbox empty validation

    hello experts help me , i want coding to find textbox empty i.e if i press button without entering any value in textbox an error msg should to be display. i'm using standard textbox and button controls .

    platform details: 3.5 ,code behind:vb
  • #486250

    check on click of button, if textbox.text is equal to "" then display messge

  • #486254
    tell me briefly plz

  • #486257
    place a button and textbox on the UI .
    double click the button

    and write the following code .

    --- ------------
    If (TextBox1.Text = String.Empty) Then
    MessageBox.Show("TextBox is empty")
    End If
    import system.IO

    hope u got it


  • #486261

    While performing validation there are two types of validations available. 1) Client side validation 2) Server side validation. Client side validation reduces time and increased efficiency of the program. client validation can be done using javascript.

    if (document.formname.fieldname.value.length == 0) {
    alert("Please fill out your name.\n");
    return false;

    All is well.
    Try and fail but don't fail and try

  • #486263
    you can use javascript for it
    Arun K
    Do not forget to Rate the post...

  • #486281
    u can use client side validation using javasript or server side write code in .cs file or use validation controls required filed validator

  • #486293
    use validation controls required filed validator

  • #486458
    Use OnClientClick event of button.

    <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="if (document.getElementById('TextBox1').value == '') { alert('TextBox empty'); return false; } else { return true; }" onclick="Button1_Click" />


  • #486550

    You Can use the Required field validator control.
    just set the control to validate propety of the validation control to the textboxid and error mesaage to what you want for error message.

    And Set the textbox and the button's Validation group to same name Lets say 'a'


    Naveen Gupta

  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.