• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 399
  • Last Modified:

Web Form Validation in C#

Hello I have a .aspx(c#) webform where a user enters his firstname, age, city, email, phone number
and in the end hits a submit button. currently i am doing validation just to know if he has entered anything or not.

I want to do something like this. when the user hits submit button we capture his values and check all values for eg: phone number shouldnt be character, email should be proper etc and if one of the validation fails we still continue and in the end we let the user know which all controls or fields have failed showing him some message on the web page like enter correct phone number, enter correct email.

I hope i made the scenario clear. how should i approach this?

thanks
0
as_coder
Asked:
as_coder
  • 2
  • 2
2 Solutions
 
silemoneCommented:
Use javascript

<FORM onSubmit="submitEvent()">  in your form tag...

when the submit button is clicked it will call that event.

then check each fiield by id

and if they don't equal what you want, then return false.
0
 
rajapandian_81Commented:
0
 
rajapandian_81Commented:
0
 
silemoneCommented:
just to touch on the server side validation -

con: they are heavier on the page.  they have to load on server side which can slow performance if you have a lot of them.  

pro: if someone turns off their javascript, server side validation will always validate.

0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now