When writing a custom VisualForce page, you commonly need to verify that required fields have been filled out.
Let's look at the code.
**NOTE** For any field that you are using a selectlist (dropdown) option you should use the onchange action instead of onkeyup.**
You may be wondering about the styleClass="mustFillOut". This is to make it super easy to grab all the fields that should be required. As long as you do not have an actual css class called "mustFillOut" you can use this on any input element you want to require - even in cascade if you have other style classes applied to the element.
Here is the actual code for the two functions, checkVal() and fieldsFilledOut() that we have been talking about.
When calling the fieldsFilledOut() function, you'll notice we display an alert to the user notifying them that they need to fill out all the required fields.
That's it! You're done!
Check back soon for a follow up post on how to make the functions dynamic enough to allow for multiple "sections" of required fields depending on which button / action you are trying to call.