Validation for catalog item in virtual agent
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-17-2024 12:54 AM
Trying to add one validation in catalog item client script for start date format for conversational chat in virtual agent. but this validation is not working. The validation is: when the end user will give a date input in the chat if it is in DD-MMM-YYYY format, then it will accept otherwise it will give an error. Attaching the code here please help me to find out where I'm making mistake or should try this in any other scripting.
function onSubmit() {
// Get the value of the v_startdate_NCR variable
var startDate = g_form.getValue('v_startdate_NCR');
// Regular expression to match DD-MMM-YYYY format
var datePattern = /^\d{2}-[A-Za-z]{3}-\d{4}$/;
if (!datePattern.test(startDate)) {
// If the date format is incorrect, show an error message and prevent form submission
g_form.showFieldMsg('v_startdate_NCR', 'Please enter the date in DD-MMM-YYYY format.', 'error');
return false;
}
// If the date format is correct, allow form submission
return true;
}
I've tried this in onSubmit, onLoad, onChange. but none of those worked
Thanks
0 REPLIES 0