You must Sign In to post a response.

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: asp.net 3.5 ,code behind:vb


Comments

#486250    Author: Maruthi Panyam    24 Mar 2010 Member Level: Gold   Points : 2

Hi,

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

#486254    Author: britto  24 Mar 2010 Member Level: Silver   Points : 2

tell me briefly plz

#486257    Author: chandrashekar    25 Mar 2010 Member Level: Silver   Points : 2

place a button and textbox on the UI .
double click the button

and write the following code .


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


hope u got it


Regards
Chandu

#486261    Author: Dharmaraj Nagarajan      25 Mar 2010 Member Level: Gold   Points : 2

Hi,

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.
Thanks,
Dharma
Editor,Mentor,MVM
Try and fail but don't fail and try

#486263    Author: Arun K    25 Mar 2010 Member Level: Gold   Points : 2

you can use javascript for it


Regards:
Arun K
http://aruninnice.blogspot.com/
Delhi
Do not forget to Rate the post...

#486281    Author: Chakrahari Muralidhar Bhattu    25 Mar 2010 Member Level: Silver   Points : 2

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

#486293    Author: Naga Shankar  25 Mar 2010 Member Level: Gold   Points : 2

use validation controls required filed validator

#486458    Author: Rajapandian    25 Mar 2010 Member Level: Gold   Points : 2

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" />

Regards,
Rajapandian

#486550    Author: naveen gupta  25 Mar 2010 Member Level: Silver   Points : 2

hello

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'

Regards

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.