I need to make variable Date(Requested by date) in such a way so that user cannot select past dates.

swapnil57
Mega Contributor

Hi All,

I have a variable set applied on service catalog item, in that "Requested by date" is a variable with type as date/time, I want if user selects date as current/previous date he should not be able to submit the request or alternatively past dates can be shown as readonly, he/she should not be able to select date in that scenario. Below is the screenshot attached.

find_real_file.pngfind_real_file.png

11 REPLIES 11

Mihir Mohanta
Kilo Sage

Write an on change client script in the Requested by date field.




function onChange(control, oldValue, newValue, isLoading){


if (isLoading || newValue == '') {


return;


}


if(newValue != '')


{


var reqDate = new Date(getDateFromFormat(newValue, g_user_date_format));


var today = new Date();


if(reqDate.getTime() <= today.getTime()) {


alert('Please select future date values');


}


}


}






Thanks,


Mihir


Hey Mihir,



Not Working.. this shows error even when we are selecting future dates as well and also if I select past dates I'm able to submit the request.


Please follow below thread .



Re: need catalog variable date to validate it is in future




Thanks,


Mihir


Harneet Sital
Mega Sage
Mega Sage

Tried this works fine.


Make a UI Policy as follows



Capture.PNG



Write following script :


function onCondition() {


      g_form.setValue('date_of_joining', '');


      alert("Enter valid date");


}


Hey Harneet,



I tried..but I dont have the same dropdown on my catalog UI policy,


find_real_file.png