Event onClick - Formular

Good day,

I need your help for a moment.

I would like to have my form “functional” only for a certain period of time.

I would have thought to cover the send button like this.

Forms should be submitted between 09:00 am and 10:00 pm.

After this time, an error message should appear when you click the button, if possible.

Would it be possible ?

Mfg Philipp

I think you can simply hide the form when it is out of the time… and show a text to tell user now is not yet able to subkit

Thanks for the answer,

Could you show me an example of how I can do this?

@riedlchamp44835 https://www.grampsworkbench.com/Examples/Open-for-Business

This is an example to tell you how to show/hide something by time

The function you want, gets the date and time and checks if it is between monday to friday, and between 9:00 to 22:00 (10PM) is this:


function checkTime() {
 var d = new Date()
 var hours = d.getHours()
 var mins = d.getMinutes()
 var day = d.getDay()
 
 return day >= 1
 && day <= 5
 && hours >= 9
 && hours < 22
}

This function just returns true or false, and if you want to do something with this, you just have to use it like this:

if (!checkTime()) { //If it is false (out of business hours)
    console.log("We're not open now!") //you can place the command you want in here
}

Tricky one!