Can topic templates have javascript?

Discourse is, at heart, a free form discussion software.

If what you really need is a strict form, you may have better results using a more appropriate software. You could embed solutions like Google Forms and Typeform to ease the transition for your users, like this example: