email – How secure is this JavaScript code?

I am following a tutorial that teaches you how to build an email verification flow and at one point I have to use the following snippet of code. I tried understanding what each line does but I would like to ask an expert if this code is safe or is there a security risk using it. Thank you!

// inject the redirect url via a hidden form field
function injectRedirectUrl(url) {
    let input = document.createElement("input");
    input.setAttribute("type", "hidden");
    input.setAttribute("name", "redirect-url");
    input.setAttribute("value", url);
    document.getElementById(form.id).appendChild(input);
}

// triggered form submit 
function captureSubmit(event) {

    // Get current form button waiting text
    let waitMessage = event.target.submitButton.getAttribute('data-wait');

    // Show waiting text
    event.target.submitButton.value = waitMessage;

    // Disable the form button
    event.target.submitButton.disabled = true;
}

// replace with your form ID
const form = document.getElementById('get-access');

// inject redirect url into a hidden form field
injectRedirectUrl(form.dataset.redirect);

// capture form submit
form.addEventListener('submit', captureSubmit);