Prevent catalog submission based on date field in text box (string field) in MRV

reddy8055
Tera Contributor

Hi,

I am populating date field in string field in MRV and want to prevent submitting the form if any of the date is more than 365 days with today's date and if it falls less than 365 days then form should be submitted.  I have written onsubmit client script but Its not checking for all date fields (in rows)

reddy8055_0-1668743136588.png

 

 

function onSubmit() {
var today = new Date();
//today.setHours(0,0,0,0);
var startDTe = g_form.getValue('course_completed_date');
//alert(startDTe);
var startDateNum = getDateFromFormat(startDTe, g_user_date_format);
var coursedate = today - startDateNum;
alert(coursedate);
var dayDifference = coursedate / (1000 * 60 * 60 * 24);
// alert(dayDifference);
if (dayDifference > 365) {
return false;
}

return true;
}

 

Thanks,

10 REPLIES 10

Did you try using UI policy?


Thanks and Regards,

Saurabh Gupta

No, date field in MRVS is string field. Can we use UI policy with date as string field? And abort submitting the form if any of the date is more than 365 days?

 

Hi,
Is there any specific need to remain date as string?
Cannot we provide user the opportunity to select the date.

How are you ensuring the correct date/format is entered by user?



Thanks and Regards,

Saurabh Gupta

Hi @reddy8055 

I think you can use a simple UI policy.

Example-

SaurabhGupta_0-1669064671631.png

UI Policy

 

SaurabhGupta_2-1669064717614.png

 

 

 

 

SaurabhGupta_1-1669064695399.png

 

Please mark the answer as correct, If I answered your query. It will be helpful for others who are looking for similar questions.

Regards
Saurabh

 


Thanks and Regards,

Saurabh Gupta

Agree to this proposal.

We implemented this also via UI Policy

- we needed to control max 365 days in the future is selected, no more

- we needed to control that end date is not less than start date

All done with 2 separate UI policies

 

/Petr