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.

Answers were Sorted based on User's Feedback



i have a register form & in that form i have a 2 textboxes for entering name&age.my doubt ..

Answer / saravanakumar

We can use RegularExpressionValidator to validate the textbox content.

Is This Answer Correct ?    2 Yes 0 No

i have a register form & in that form i have a 2 textboxes for entering name&age.my doubt ..

Answer / 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

i have a register form & in that form i have a 2 textboxes for entering name&age.my doubt ..

Answer / satheshkumar

name textbox should follow the reqularexpersion valitator and age textbox should follow the range validator

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More ASP.NET Interview Questions

Can we set which type of comparison we want to perform by the CompareValidator control?

0 Answers   MindCracker,


which directive is mandatory in page control

3 Answers   AG Technologies,


what is the generics and where used generics in your project?

3 Answers   CTC,


What are clr?cts?cls?

4 Answers   e4e, HCL, Microsoft, Tata Communications,


Which is the parent class of the ASP.NET server control?

0 Answers   Sans Pareil IT Services,






What is the use of web.config file?

0 Answers  


Explain how inline and code behind is used differently ?

1 Answers   Siebel,


If I m using Session State Partioning where I have partitioned my session into 4 servers then how can I know that my session will be stored on which server?

1 Answers  


How can we access static variable?

0 Answers  


What is the difference between application object and session object?

4 Answers   IBS,


What is difference b/w Data Grid in ASP.Net 1.1 and Gridview in 2.0

11 Answers   Bosch, IntraLogic,


What are skins?

1 Answers  


Categories