i have a register form & in that form i have a 2 textboxes
for entering name&age.my doubt is that how can i provide
error message like "invalid entry" when user enter a
invalid name/age(eg:user enter name as #%%%##daff,and age
as 1000.)in that textboxes.I want code.

Answer Posted / rajeev kumar varshney

char[] SpecialChars = "#%".ToCharArray();
string text=TextBox1.Text;


int indexOf = text.IndexOfAny(SpecialChars);

if(indexOf != -1)
{
Page.ClientScript.RegisterStartupScript("this.getType(),"a","<script>alert('Please do not enter % or # in name');</script>");

}

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is view state management in asp net?

561


What is special types forms

628


How Session outproc in Sqlserver stored?

2404


What are the disadvantages of view state?

707


Are cookies client side or server side?

580






What is asp.net and its advantages?

619


To display data in the combo box, prior to setting the Data Source, what kind of property on a Combo Box do you set with a column name?

698


What is authentication in asp.net?

672


What's the difference between viewstate and sessionstate?

660


What does postback mean?

623


What is the purpose of master page?

609


How can you implement the postback property of an asp.net control?

626


In which event of the page viewstate is available?

549


How does asp.net work?

639


Why is global asax is used?

699