- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-16-2016 01:15 AM
Hi,
I've the following script that allows not to select any past dates. But I would like to modify this to select the current date and any future dates. Please advise. Thanks ! function onChange(control, oldValue, newValue, isLoading, isTemplate) { if (isLoading || newValue == '') { return; } var d = getDateFromFormat(newValue, g_user_date_format); var today = new Date(); if (d < today) { alert('The date value cannot be before the current date and time. Please correct.'); g_form.clearValue("effective_date"); } }
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-16-2016 04:08 AM
Hi Imran and All,
Let us make this very very simple.
We will make a UI Policy with this condition :
here manufacture_date is the field which I'm checking if a past date is not entered. Replace it with your own variable name.
And now we just write a 2 line code in the "Script" part of the same UI Policy :
And that's it guys. We are good to go. We need not use any client scripts because for form validations the best practice is to use UI Policies. Using client scripts would have performance issues.
Please let me know if you have further doubts.
Thanks,
Arnab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-19-2016 02:43 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-16-2016 01:57 AM
Hi,
function onChange(control, oldValue, newValue, isLoading) {
if(isLoading || newValue == '') {
return;
}
var date = new Date();
var dateEntered= new Date(getDateFromFormat(g_form.getValue('end_date'),g_user_date_time_format));
if (dateEntered< date) {
alert('End date must be in the future.');
g_form.clearValue('end_date');
}
Please see if this helps..
Regards
Param
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-16-2016 04:08 AM
Hi Imran and All,
Let us make this very very simple.
We will make a UI Policy with this condition :
here manufacture_date is the field which I'm checking if a past date is not entered. Replace it with your own variable name.
And now we just write a 2 line code in the "Script" part of the same UI Policy :
And that's it guys. We are good to go. We need not use any client scripts because for form validations the best practice is to use UI Policies. Using client scripts would have performance issues.
Please let me know if you have further doubts.
Thanks,
Arnab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2018 04:03 PM
Hey Arnab, the solution didn't work for me. I am on Jakarta.
I have a date field, and set the UI policy as you outlined, but it doesn't show any error if I select any past date. Can you "please" point out what am I doing wrong:
The Script:
function onCondition() {
g_form.setValue('class_start_date', '');
alert("Enter valid date");
}
And set the UI Policy {since Variable is under a Variable set, does it make any difference?}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-27-2018 06:09 PM
Hi Arnab,
I have a scenario on catalog item where,
when user selects a date for a variable called 'X' and then
there is another variable for example: 'Y' which will be a select box of questions 1,2,3,4.
Based on the selection of this question, the start and end dates will be shown. So if i select '3' for the variable 'Y' then, three start and end dates will be shown and these end dates should not be future date of 'X' variable date selected and the start date should be equal or less than the end date. In this case what should be the complete script to achieve this task? I have no idea as i am very new to such requirement. Could you please help??