Prevent JS error in IE when the form attribute is used on an input

In IE if the `form` attribute is present on an `input` element, the `form` property returns the value of the attribute (which should be the ID of a form element in the same document). This PR prevents a JS error that was thrown because we were assuming the value of `element.form` was always `null` or a DOM element.