Just found out the issue comes from this particular website having input field’s name set to “name”, which in turn makes form.name
not be a string name attribute of <form>
element, but rather the <input>
with name="name"
in this form:
.toLowerCase()
being called on the <input>
element rather than string value.
Solution: use form.getAttribute('name')
rather than form.name
(same for form.id
and similar code parts)