Forums » .NET » ASP.NET »

Textbox empty validation


Posted Date: 24 Mar 2010      Posted By:: britto     Member Level: Silver    Member Rank: 574     Points: 1   Responses: 9



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




Responses

#486250    Author: Maruthi Panyam      Member Level: Gold      Member Rank: 0     Date: 24/Mar/2010   Rating: 2 out of 52 out of 5     Points: 2

Hi,

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


 
#486254    Author: britto      Member Level: Silver      Member Rank: 574     Date: 24/Mar/2010   Rating: 2 out of 52 out of 5     Points: 2

tell me briefly plz

 
#486257    Author: chandrashekar      Member Level: Silver      Member Rank: 1438     Date: 25/Mar/2010   Rating: 2 out of 52 out of 5     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        Member Level: Gold      Member Rank: 17     Date: 25/Mar/2010   Rating: 2 out of 52 out of 5     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      Member Level: Gold      Member Rank: 112     Date: 25/Mar/2010   Rating: 2 out of 52 out of 5     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      Member Level: Silver      Member Rank: 999     Date: 25/Mar/2010   Rating: 2 out of 52 out of 5     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      Member Level: Gold      Member Rank: 208     Date: 25/Mar/2010   Rating: 2 out of 52 out of 5     Points: 2

use validation controls required filed validator

 
#486458    Author: Rajapandian      Member Level: Gold      Member Rank: 238     Date: 25/Mar/2010   Rating: 2 out of 52 out of 5     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      Member Level: Silver      Member Rank: 1457     Date: 25/Mar/2010   Rating: 2 out of 52 out of 5     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


 
Post Reply

 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.



Return to Discussion Forum
Start new thread

Subscribe to Subscribers
Active Members
TodayLast 7 Daysmore...

Awards & Gifts
Talk to Webmaster Tony John
Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India