Often times you just need to make sure that required fields are entered. Let's look at an example. Let us say that you are wanting to collect information from your users about how they rate your site. We would want to write a JavaScript function to ensure that the name field had a value in it, and that the site ranking had a value between 1 and 10 in it. Check whether string s is empty.
All characters are whitespace.
Another good tip is to validate data on ALL fields in your forms. I know this may seem tedious and boring, but nothing is worse than having SQL errors, or inconsistent data in your database. Further down in this article, you will find several JavaScript examples for various types of validation. Feel free to use these on your web site. It is wise to make your data validation functions as portable as possible.