you shouldn't throw bare strings in JS.  You want to do:
throw new Error('The form element should be defined.');