Allow user to select date if is more than 15minutes

Zuri
Tera Expert

I want to allow user to select date and time if is more than 15 minutes from current date and time. Below onChange client script I am not able to select previous date but I am able to select anytime after current time. I want to allow only to select when time is 15 minutes or more from current time.

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}

//Type appropriate comment here, and begin script below

var date = new Date();
var sd = new Date(getDateFromFormat(g_form.getValue('date'), g_user_date_time_format));

if (sd < date) {

g_form.clearValue('date);
g_form.showFieldMsg('date', "Start date must be in the future.", 'error');
jslog('txt');
}


}

1 ACCEPTED SOLUTION

Is working but after I submit a form with correct time and go back and change time to less than 15 minutes is updating the form without any error

View solution in original post

28 REPLIES 28

Thank you @Giles Lewis  the issue I am having right now is not to allow user from selecting time when is below 15minutes. I want to allow selection when is more than 15 minutes.

Nikhil Mahepath
Mega Expert

Hi Zuri,

 

A simple UI policy resolves the requirement as follows:

find_real_file.png

and script as follows:

find_real_file.png

 

If this resolves your query. Please mark as helpful and correct.

 

Regards,

Nikhil Kumar M

Aelum Consulting pvt ltd

UI policy is clearing the value without displaying error message under the field name. I need error to be display under the field not on top of the form

find_real_file.png

Please share your code here. Also, cross check the field name that has been used in script