diff --git a/core/misc/form.es6.js b/core/misc/form.es6.js
index 06a53b2c75..d4ba911bd5 100644
--- a/core/misc/form.es6.js
+++ b/core/misc/form.es6.js
@@ -288,7 +288,7 @@
     }
     const hash = url.hash.substr(1);
     if (hash) {
-      const $target = $(`#${hash}`);
+      const $target = $(`#${hash.replace(/[^0-9a-zA-Z]/g, '\\$&')}`);
       $('body').trigger('formFragmentLinkClickOrHashChange', [$target]);
 
       /**
diff --git a/core/misc/form.js b/core/misc/form.js
index 88226a5156..3da6c657ba 100644
--- a/core/misc/form.js
+++ b/core/misc/form.js
@@ -134,7 +134,7 @@
     }
     var hash = url.hash.substr(1);
     if (hash) {
-      var $target = $('#' + hash);
+      var $target = $('#' + hash.replace(/[^0-9a-zA-Z]/g, '\\$&'));
       $('body').trigger('formFragmentLinkClickOrHashChange', [$target]);
 
       setTimeout(function () {
