Client Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-18-2024 04:35 AM
function onSubmit() {
var terminationDate = g_form.getValue('actual_end_date');
var extensionDate = g_form.getValue('extension_date');
var currentDate = new Date(); // Get the current date
// Convert terminationDate to Date object for comparison
terminationDate = new Date(terminationDate);
// Check if Termination date is the same as the present date
if (terminationDate.toDateString() === currentDate.toDateString()) {
alert('Termination date cannot be the present date.');
return false;
}
// Check if Extension date is before Termination date.
if (extensionDate <= terminationDate) {
// Prevent the form from being submitted
alert('Extension date cannot be before Termination date.');
return false; // This prevents the form from being submitted
}
// If validation passes, allow the form to be submitted
return true;
}
Termination date should not be present date, it should be future date.Where i am going wrong in this script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-18-2024 04:51 AM
Hi @HARSHA GOWDA R ,
Try this code, I've slightly modified the logic.
function onSubmit() {
var terminationDate = g_form.getValue('actual_end_date');
var extensionDate = g_form.getValue('extension_date');
var currentDate = new Date(); // Getting the current date
// Converting terminationDate to Date object for comparison
terminationDate = new Date(terminationDate);
extensionDate = new Date(extensionDate);
// Checking if Termination date is the same as the present date or before the present date
if (terminationDate <= currentDate) {
alert('Termination date should be a future date.');
return false;
}
// Check if Extension date is before Termination date
if (extensionDate <= terminationDate) {
// Prevent the form from being submitted
alert('Extension date cannot be before or on the Termination date.');
return false; // This prevents the form from being submitted
}
// If validation passes, allow the form to be submitted
return true;
}
Thanks,
Hope this helps.
If my response proves helpful please mark it helpful and accept it as solution to close this thread.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-18-2024 05:00 AM
Hi @HrishabhKumar
It's not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-18-2024 05:07 AM
Are you able to get the alerts?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-18-2024 05:08 AM
Nope