Universal Form Validation - And Knowing is Half the Battle
(Page 5 of 5 )
In this example, I’ve removed the prefixes ‘data_’ and ‘process_’ from the fields, and therefore commented that part out of the form checker. I had these in place for the use of universal form handlers. You are beginning to suspect that I like to use the word ‘universal’, and you’re right; it makes things sound big and important.
Anyway, these handlers took the form of mail processors, dynamically generated forms for various uses within a Content Management System, and for other non-interesting items like surveys and such.
My philosophy is that if you put enough thought and work into something, you should be able to use it again and again with the greatest of ease. And if you want to make a modification (eg: adding the regular expression to check email addresses) you only have to change that in one place, not in a million forms within your application.
You should be able to copy & paste this code directly into your own ‘forms.js’ without any further configuration needed. I have no doubt however that you will make many marvelous modifications to suit your own very unique needs. Feel free to drop me a note, and share any that you have found particularly useful!
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |