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

Differentiate between a page theme and a global theme?

519


How will you do Redo and Undo in a TextControl?

664


What is cross page posting in asp net?

530


Is LINQ performance wise better or using sqlcommand?

4327


How to use multiple scriptmanager controls in a web page?

595






What are session state modes in asp.net?

544


What is asp.net version?

521


What is the difference between mvc (model-view-controller) and mvp (model-view-presenter)? : asp.net mvc

532


What are session state modes? List some of the important session state modes of asp.net.

525


How to prepare culture-specific formatting in .net.

507


Name the namespace which is used by ado.net?

519


Explain how viewstate is being formed?

533


How long do session variables last?

526


What are the two Layouts supported by a Web form in ASP.NET?

548


How you can access the values from the Repeater control in ASP.NET?

571