Help center JavaScript cookbook



image avatar

Charles Nadeau

Zendesk Documentation Team

Edited May 07, 2025


7

37

41 comments

Hey Tipene Hughes

The date field is just the custom date field that the user can edit. 

0


Hey T5 Admin,

Would you mind sending through a snippet of how your custom date field is currently functioning and I can put together a working example based on your code.

Thanks!

Tipene

0


Hey, 

I'm trying to make it so that a custom date field can't select a date in the past. Is that possible?

0


Hi Adam,
 
I'm glad to hear that you were able to find a suitable solution. Please don't hesitate to reach out anytime if you need further help or questions. 

Have a wonderful day ahead!
 
 
 
Kind regards, 

0


Hey DJ Buenavista Jr.

Thank you for your recommendation.

I was able to find another solution with one of our Javascript engineers and is working as expected. I'll certainly keep the options you've shared in my back pocket if I have any issues with the one I'm using.

const links = document.querySelectorAll("a");
  for (const link of links) {
    link.addEventListener('click', function (e) {
    if (e.target.href == 'http://google.com') {
        e.preventDefault();
        window.open(link.href, '_newtab' + Date.now());
      }
    });
}

0


Hi Adam,
 
In regards to your concern, the following script involves custom coding. I would advise searching online for solutions, but I have found some from looking online. 
 
You can check an example from StackOverflow, here. Another one for reference can be found here. 
 
Thank you and have a wonderful day ahead!
 
 
Kind regards,

0


Hello,

I'm looking for help on ticket forms in the Help Center. We currently have a URL in the description of a custom field. This allows our customer to reference the information on this page while filling out the form.

The issue we have discovered is that when the customer clicks on the link it opens the URL in the same window as the Help Center. 

Does anyone one know how to capture this via Javascript and force the link to open into a new tab within the users browser?

1


Hi Shawn,

Are you trying to autofill a dropdown field on a ticket form? If yes, the Creating pre-filled ticket forms will help you

-1


Is it possible to autofill a field that is a dropdown menu field?  Or does that only work for text entry fields?  I can successfully hide fields on various forms and autofill text fields like the subject and description, but I have not been successful with drop menus.

Thanks!

0


Olá Leonardo Ribeiro Da Silva!

Você pode dar uma olhada nessa outra documentação aqui referente à formulários e marcas :)

Esperamos que isso ajude, mas qualquer dúvida, entre em contato com o Suporte - Contato com o suporte ao cliente Zendesk.

0


Sign in to leave a comment.