Table of Content:
- Validation: Have a Strategy
- A Validation Library
- What is a Regular Expression?
- How We'll Build It
- A Word About Validation Techniques
- Empty Fields
- The Form
- The isEmpty() Function
- Conclusion
We build a main validation function that automatically runs the right "sub" function for each field. We'll tell the main function which sub function to run by including the sub function name in the element ID and extracting it. This makes an abstract function that can be placed in any file. Then what you actually put in the tags determines the validation.
You won't have to necessarily edit the main function all the time, which is the part that can become really tedious and error-prone, and can be reused again and again.