Moved frontend logics from template to form.js