
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2024 10:23 PM
Hi Team,
I need alret message if select more then 12 hours in duration variable
I tried below client script and script include but it works
Client script
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2024 01:40 AM - edited 07-24-2024 01:40 AM
Hi @Community Alums ,
Please try the below:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var duration = g_form.getValue('how_long_do_you_need_access');
var parts = duration.split(" ");
var selectedDay = (parts.length > 1) ? Number(parts[0]) : 0;
var selectedHour = Number(parts[parts.length - 1].split(":")[0]);
var selectedMin = Number(parts[parts.length - 1].split(":")[1]);
var selectedSeconds = Number(parts[parts.length - 1].split(":")[2]);
var daysInHrs = selectedDay * 60; //Converting days into hours
var minInHrs = selectedMin / 60; //converting mins in hrs
var secInHrs = selectedSeconds / 3600; //converting secs in hrs
var finDur = daysInHrs + selectedHour + minInHrs + secInHrs;
//alert("Selected Days: " + selectedDay + " \nhours: " + selectedHour + " \nMinutes: " + selectedMin + " \nSeconds: " + selectedSeconds + " \nFinalDur: "+ finDur);
if (finDur > 12) {
alert('More than 12hrs detected');
}
}
More than 12 hrs selected:
Mark this as Helpful / Accept the Solution if this helps
Mark this as Helpful / Accept the Solution if this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2024 11:29 PM
Hi @Community Alums ,
You can achieve this in the client side only. No need to call the script include. Please take a look at the below sample script:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var duration = g_form.getValue('how_long_do_you_need_access');
var parts = duration.split(" ");
var selectedDay = (parts.length > 1) ? Number(parts[0]) : 0;
var selectedHour = Number(parts[parts.length - 1].split(":")[0]);
var daysInHrs = selectedDay * 60; //Converting days into hours
alert("Selected Days: " + selectedDay + " \nhours: " + selectedHour + "\nDayInHrs: " + daysInHrs);
}
Now, you can simply compare them and alert the message as per the requirement.
Mark this as Helpful / Accept the Solution if this helps
Mark this as Helpful / Accept the Solution if this helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2024 12:41 AM
Hi @SN_Learn ,
Thank you for the solution.
It works only for if giving 13 hours .if i am giving 12 hours 1 mint it not works
I need count mints also .if select more the 720 need get alert msg.
Thank you,
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2024 01:40 AM - edited 07-24-2024 01:40 AM
Hi @Community Alums ,
Please try the below:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var duration = g_form.getValue('how_long_do_you_need_access');
var parts = duration.split(" ");
var selectedDay = (parts.length > 1) ? Number(parts[0]) : 0;
var selectedHour = Number(parts[parts.length - 1].split(":")[0]);
var selectedMin = Number(parts[parts.length - 1].split(":")[1]);
var selectedSeconds = Number(parts[parts.length - 1].split(":")[2]);
var daysInHrs = selectedDay * 60; //Converting days into hours
var minInHrs = selectedMin / 60; //converting mins in hrs
var secInHrs = selectedSeconds / 3600; //converting secs in hrs
var finDur = daysInHrs + selectedHour + minInHrs + secInHrs;
//alert("Selected Days: " + selectedDay + " \nhours: " + selectedHour + " \nMinutes: " + selectedMin + " \nSeconds: " + selectedSeconds + " \nFinalDur: "+ finDur);
if (finDur > 12) {
alert('More than 12hrs detected');
}
}
More than 12 hrs selected:
Mark this as Helpful / Accept the Solution if this helps
Mark this as Helpful / Accept the Solution if this helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2024 01:52 AM
Thank you so much @SN_Learn It works
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2024 11:31 PM