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 mta?

786


What is the use of web.config and machine.config files?

841


What is the maximum amount of memory any single process on windows can address?

743


What is data reader in asp.net?

742


Why will you usually create an aspnet user account in the database for an asp.net web application?

737


How long the items in ViewState exists?

1171


Securitywise What are the Enhancements in 2.0?

1670


What is repository pattern in mvc.net? : asp.net mvc

707


What is difference between abstract class and an interface?

697


Define secured sockets layer.

696


How does the iis work?

770


Differentiate between Server.Transfer and Response.Redirect with functionality? Why we can choose one over the other?

846


Explain the differences between clr & cts?

738


What are the main requirements for caching?

745


Where the cookie value is stored?

702