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);

// triggered form submit 
function captureSubmit(event) {

    // Get current form button waiting text
    let waitMessage ='data-wait');

    // Show waiting text = waitMessage;

    // Disable the form button = true;

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

// inject redirect url into a hidden form field

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