On Submit script is not working as expected
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2024 06:10 AM
Hi Team,
I am trying OnSubmit script to validate Actual Start and Actual End date of the change Task. Actual End date can not be before start date, if we enter start date as 28 and end date as 27 then it should not save the form on submit or save Ui action. But even after providing wrong dates its showing alert and form is getting saved. Logs returns correct value, issue is with saving the form.
it also has on change script for similar logic. Can anyone help on how to resolve this issue.
Regards,
Apoorva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2024 06:31 AM - edited 06-04-2024 06:36 AM
If both on change and onload scripts are active then it might be overlap. Also, Instead of alert messages please add error messages/ field messages and if required to stop submitting the form after error then try by adding abort action.
If the fields are mandatory then you can clear values of that fields after/ before the error message.
If my solution helps you any way then mark it as accepted and helpful.
Thank You!!
Thank you!!
Dnyaneshwaree Satpute
Tera Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2024 04:16 AM
Hi Dnyaneshwaree,
On Change and Onsubmit are active and i have tried with abort it is not working, Alerts i have added in order to test. On Change has valid messages to display when user enters invalid dates.
Regards,
Apoorva

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2024 05:13 AM
Hello,
It seems like there might be an issue with how the validation logic is implemented in the onSubmit script. Let's refine the logic to ensure that the form is not saved if the Actual End date is before the Actual Start date.
Here's how you can adjust the onSubmit script to achieve this:
function onSubmit() {
var actualStartDate = g_form.getValue('actual_start');
var actualEndDate = g_form.getValue('actual_end');
// Check if Actual End date is before Actual Start date
if (actualEndDate && actualStartDate && actualEndDate < actualStartDate) {
// Prevent the form from being submitted
alert('Actual End date cannot be before Actual Start date.');
return false; // This prevents the form from being submitted
}
// If validation passes, allow the form to be submitted
return true;
}
Make sure you replace 'actual_start'
and 'actual_end'
with the actual field names for the Actual Start and Actual End date fields on your form.
Also, ensure that this script is added as the client script for the onSubmit Client Script of the relevant table.
Regards,
Vaishnavi Lathkar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2024 01:24 AM