Pure Javascript validation is almost certainly wrong in ASP.NET, it only checks on the client, not the server, and a this is insecure.
ASP.NET has validation controls built in:
MSDN Validation Controls[
^]
All of these generate the JavaScript and validate on the server too (except the CustomValidator: You write the server and client scripts for yourself). The validators are:
RequiredFieldValidator
- The validated field must not be blankCompareValidator
- Compares against a value, or value of another controlRangeValidator
- Makes sure the value is in a pre-defined rangeRegularExpressionValidator
- Makes sure the value matches a regexCustomValidator
- Complex Validation you define yourself.ValidationSummary
- Allows you to summarise validation failures