18 most common validation scripts to validate the Controls in ASP.Net


The article will explain about the validation scripts which can be used to validate the fields and controls of the web form. These all scripts are binded in to a JavaScript so that the programmer can directly add/include it to their webpage .aspx and the they can use it. Also this script file is modifiable so that they can also include few more scripts if they require, they can also modify as per their business needs.

Many times, we search in the Google to get the correct validations expression to validate our web page controls. And its true that we get lot of various links where people have given their own code for validations controls by using some scripts, regular expressions etc.
Then we copy and implement those expressions and at the end, we found that it's not working and again we start our search for the next link. It becomes very problematic whenever we have to fix the validation issues in a very less time and then we didn't get the correct expression.

So dear folks, now nothing to worry as I created a CommonScripts.js file which contains the 18 most used common validation expressions and they all are tested from my projects.

Like you, I also did the same in searching through Google but failed and the i decided to create a file which will contains all the general use validation expressions to validate our controls.

See below the expression for the various purposes:
1. Show confirm box
1. Show confirm box
2. Show Alert box
2. Show alert box
3. Validate mandatory check
3. Validate mandatory check
4. Script to compare two dates(From Date and To Date)
4. Script to compare two dates(From Date and To Date)
5. Script to compare salary(Min Salary and Max Salary)
5. Script to compare salary(Min Salary and Max Salary)
6. Script to compare service(Min Service Period and Maximum Service Period)
6. Script to compare service(Min Service Period and Maximum Service Period)
7. Validate numbers
7. Validate numbers
8. Validate numbers with padding
8. Validate numbers with padding
9. Validate last name as Mandatory field and the user should enter
at-least 2 letters

9. Validate last name as Mandatory field and the user should enter at-least 2 letters
10. Validate alphanumeric
10. Validate alphanumeric
11. Validate alphanumeric with apostrophe(')
11. Validate alphanumeric with apostrophe(
12. Validate number with a .(dot)
12. Validate number with a .(dot)
13. Validate number with a .(dot) and Comma(,)
13. Validate number with a .(dot) and Comma(,)
14. Validate salary
14. Validate salary
15. Format Non-US currency
15. Format Non-US currency
16. Format US currency
16. Format US currency
17. Validate Yes/No status
17. Validate Yes/No status
18. Validate range numbers
18. Validate range numbers
I have attached the document as well as the CommonScripts.js file for your reference so that the file can be included as is in to your projects.


Attachments

  • Validation Document (43752-7198-Validation-Document.docx)
  • CommonScript.js (43752-7190-CommonScripts.js)
  • Comments

    No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: