Home > Forum > Forms > Attribute as time

Attribute as time
0

I have a question:
How to create a field/attribute with only the time selection (without the date)?
Thank you in advance for your help

MVP
In reply to: User

I would like to create a form where the user will have two attributes to choose from:
1. Hour from:
2. Hour to:
So instead of selecting the date and time, there will only be time.

You could use:
* 2 Decimal fields with 0 decimal places, and suffix 'h'. + Validation on exit which will check if first number is smaller than second, and if both are smaller than 25.
* 1 or 2 Text fields with regex, that will validate input format. + Similar validation on exit.

I would rather go with Decimal fields, as it will be easier to make some math, an validation on it.
Second option will give faster feedback about the input, thanks to regex though.

MVP

Hi,
I don't know if it will help, but I used html field with javascript for hour field.
I attached the code javascript and html:



async function setOraPlecarii()
{
var b=document.getElementById("oraPlecarii").value;
await SetValue('#{FLD:1249}#', b);
}
async function SetareNrzileDiurnaP()
{
await setOraPlecarii()


}
function setPlecare()
{
document.getElementById("oraPlecarii").value=GetValue('#{FLD:1249}#');
if(#{ST:240}#!=#{STP_ID}# && #{ST:242}#!=#{STP_ID}# )
{
var field = document.getElementById('oraPlecarii');
field.disabled = true;
}
else{
var field = document.getElementById('oraPlecarii');
field.disabled = false;
}

}



window.onload = setPlecare();






Thanks,
Raluca

Did you know that with WEBCON you can automate virtually any process? Even baking cookies 🍪
 
Speaking of cookies: we use the ones that are essential for our website to function properly, as well as additional ones that help us customize our content to your preferences. If you don’t mind cookies, click Accept. If you want to learn more, explore settings.
Settings