implemented form validation basics, fixed some JS form generation bugs