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

Why session is necessary in web application?

509


What do you mean by authorization?

518


Can more than one person use the same login?

570


Explain the difference between dataset and datareader.

527


How to use ipostback?

590






Write code to send e-mail from an asp.net application?

544


To bind columns manually which tags do you need to add within the asp:datagrid ?

549


In a webservice, need to display 10 rows from a table. Which is the best choice among datareader or dataset?

649


Where the assembly is stored in asp.net?

550


Explain cookies with example.

553


What is the benefit of WebAPI over WCF?

565


Describe the differences between the lifecycles of Windows services and Standard EXE?

597


What is difference between session and cookies in asp net?

500


How can you identify that the page is post back?

551


How can we prevent browser from caching an aspx page?

527