In incident form only today date field iwant not previous date and future date by using on submit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2024 04:11 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2024 08:46 PM
So you want to restrict the user to select only Today's date in a date time field on the incident form ? If yes, on which field you want to enable this restriction ?
You can refer below posts which could be helpful :
Thanks & Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2024 10:42 PM
can we connect
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2024 09:02 PM
Hi @patanfarjana110 ,
Why do u want to go with onSubmit script when u can achieve this with less code via a UI policy.
In UI policy add condition if selected field is after today's date or before today's date n under script tab just mention run script as All n under execute if true u can just print an alert stating " Only Today's date can be selected"
But if u still want to go with onSubmit script
Plz try below code n check if it works
function onSubmit() {
var todayDateField = g_form.getValue('today_date_field'); // Replace 'today_date_field' with the actual field name
var currentDate = new Date().setHours(0, 0, 0, 0); // Get the current date with time set to 00:00:00:000
var selectedDate = new Date(todayDateField).setHours(0, 0, 0, 0); // Get the selected date with time set to 00:00:00:000
if (selectedDate !== currentDate) {
alert('Please select today\'s date.'); // Display an alert if the selected date is not today
return false; // Prevent form submission
}
return true; // Allow form submission
}
Thanks,
Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2024 09:12 PM
Hi @patanfarjana110 ,
Go to the field dictionary > default value
Set the value to :
javascript:gs.glideDatenow()
Why go with Onsubmit client script?
☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....