1. I need to validate that user has entered something/correct things in the fields that are required before submitting it and give the user a warning/response (external javascript I presume or are there a built in in Joomla function for this?)
2. I need to validate that user has entered something/correct things in the fields that are required when processing and inserting into the database
3. I need to secure the things that the users are entering (I've seen functions that seem to be related to this but I don't know how and when to use them)
4. I need to secure the things that are fetch from the database and outputted on the page (I've seen functions that seem to be related to this but I don't know how and when to use them)
All help and any pointers are gladly accepted.

EDIT: ("Doh!") Might be helpfull to add that I'm talking about Joomla 1.5