Hello,
I've been developing a mail filtering extension, but have run into a small problem. I want to check if a mail is allowed to register using JavaScript. I have written everything that would allow me to store regex patterns and exact emails, but am out of ideas how to override SignUpModal
's onsubmit
function.
I have tried to substitute its onsubmit
for my own version, but SignUpModal
is always undefined. I'm a complete noob to js, in fact, the first time I touched it was yesterday, yet it can't get around this.
Basically, what I'm trying to do is check if the e-mail to be submitted for registration is valid. If it is, I'd simply call the existing onsubmit
function. If not, I'd show an error and let the user re-enter their e-mail. At this point I'm thinking about creating a class extension of the Modal, overriding its onsubmit
and then try and substitute that Modal as a SignUpModal
but I'm not sure how to do that either.
I know that I can do it fairly easily with PHP, but I want to avoid running it on the server, at least for now.
Any help would be appreciated.
EDIT: This is what I've come up with until now:
import { override } from "flarum/extend";
import SignUpModal from "flarum/components/SignUpModal.js";
export default function()
{
override(SignUpModal.prototype, "onsubmit", function(original)
{
console.log("Prepended!");
original();
});
}