24hrs time validation for string field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2022 10:38 PM
In-Time and Out-Time must be between 00:00 to 23:59 format and Out-Time must be greater than In-Time
Refer attached img.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
var str = g_form.getValue('in_time');
var regex = new RegExp(/^\d?\d:\d{2}$/).test(str);
if (str == null) {
g_form.showFieldMsg('in_time', 'Please use the right format.', 'error');
return "false";
}
if (regex.test(str) == true) {
return "true";
} else {
return "false";
}
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-24-2022 02:42 AM
Hi,
Here is a regular expression that will cover the time validation,
your current one will allow for entering a time like "39:89"
^([0-1]?[0-9]|2[0-3]):[0-5][0-9]$