End_date should not be less than Start_date (Date/time variables)

Southsayer
Tera Expert

Hi Guys,

I have two date/time variables with names campaign_start_date and campaign_end_date on the catalog item view.

I need to check if the campaign_end_date is less than campaign_start_date, I need to clear campaign_end_date value and show a field message. 

 

is there a way to do that using the Catalog UI policy? if yes, please help me out using the catalog UI Policy because it is my first preference. 

if not, could you please provide me with the catalog client script code?

 

thanks in advance

1 ACCEPTED SOLUTION

I am using Catalog UI Policy.

 

Condition: compaign_start_date  is more than  0  Hours  after  compaign_end_date

MuhammadKhan_0-1666881793928.png

MuhammadKhan_1-1666881823368.png

 

Script: g_form.clearValue('compaign_end_date');

g_form.showFieldMsg('compaign_end_date', 'End Date must be at or after start date.', 'error', true);

MuhammadKhan_2-1666881856223.png

 

View solution in original post

6 REPLIES 6

I am using Catalog UI Policy.

 

Condition: compaign_start_date  is more than  0  Hours  after  compaign_end_date

MuhammadKhan_0-1666881793928.png

MuhammadKhan_1-1666881823368.png

 

Script: g_form.clearValue('compaign_end_date');

g_form.showFieldMsg('compaign_end_date', 'End Date must be at or after start date.', 'error', true);

MuhammadKhan_2-1666881856223.png

 

Gontla Mythily
Tera Expert

Hi,

 

You can achieve this by using catalog client script(onChange).

 

GontlaMythily_0-1666878086358.png

 

var a = g_form.getValue("end_date");
var b = g_form.getValue("start_date");
if(a<b){
g_form.addErrorMessage("fd");
g_form.clearValue("end_date");
}else{
g_form.clearMessages();
}

 

Mark as correct if it helps
Regards Mythily