Unsure what you're HTML looks like, but the javascript is fine
I assume you're not calling the function somewhere?
Heres a working example which calls the function inside a form:
https://codepen.io/Jaromme/pen/poOLYoGThis post was edited by Strickland on Mar 14 2023 01:37pm