Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hii to all,
Though iam not new to .Net but iam new to MVC,iam learning MVC3 by doing simple exercises,here i got an requirement that i need to validate my textbox with different scenarios like
1)Wheather the user entered the data in the textbox r not?
2)Textbox should accept only digits
3)The No entered in Textbox1 should be always greater than Textbox2
4)The No entered in the Textbox Should not be Zero
5)E-mail ID format,Password Format
please help me with code how can i achieve above validations,is there any validation controls like in our ASP.NET i.e Required Field,Regular Expression,Range Validator etc...


Thanks
Ramu
Posted

1 solution

Hi Ramu,

I am glad that you are trying MVC. I am also like you when I tend to learn MVC at first.
Validation in MVC can be done in two ways as I know

1) Using Model class

http://msdn.microsoft.com/en-us/library/dd410404(v=vs.90).aspx[^]

2) Without using Model class

Try this LINK[^]
Model Validation in ASP.NET MVC[^]

Hope this might be helpful for you.

Regards,
RK
 
Share this answer
 
v2
Comments
Rockstar_ 29-Apr-13 7:20am    
very good links..
Rockstar_ 29-Apr-13 7:20am    
Even I'm learning...
♥…ЯҠ…♥ 29-Apr-13 7:22am    
cheers buddy.....
StianSandberg 29-Apr-13 7:28am    
good answer! 5'ed
♥…ЯҠ…♥ 29-Apr-13 7:30am    
thanks pal..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900