Search day, time and add class to a form

Asked

Viewed 26 times

-3

I asked a question a while ago here and they helped me a lot. I managed to make a code searching the day of the week (Saturday and Sunday) and adding a class to the form to disable it. Follow:

jQuery(document).ready(function($) {
    now = new Date
    var idBotaoEnviar = $("#form-reserva");
    now.getDay() == 0  || now.getDay() == 6 || now.getDay(5) && now.getHours() >= 18 ? '' : $(idBotaoEnviar).addClass('ativado')
    console.log(now)
});

I needed to add a shape to this code that when it’s Friday after 7:00 pm, it adds the class also to disable the form.

This code above is adding the class every day after 19h.

Can you help me? I really appreciate it. I’m pretty new to what you can see. Thank you!

1 answer

0

You got the code done, just adapt.

now.getDay() == 5 && now.getHours() >= 19 ? '' : $(idBotaoEnviar).addClass('desativado');
  • Okay my friend, thank you very much for your help. I will adjust there and put here the result.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.