Brady Ward
92 posts
Registered:
19 Aug 2021
Answered
09 Feb 2022
in reply to
jahanzaib shahid
Link to this post
Hello Jahanzaib,
You can use the following code snippet with minor edits to the selected form, the format and validation message:
$(document).on("tpc:ready", function(event, tpcObject){
tpc.forms[0].$$instance.get_kendoValidator().options.rules.dateValidation = function (input, params) {
if (input.is("[data-role='datepicker']") && input.val() != "") {
input.attr("data-datevalidation-msg", "You must use the following format: MM/dd/yyyy");
var date = kendo.parseDate(input.val(), "MM/dd/yyyy");
if (date) {
return true;
}
return false;
}
return true;
}
});
The above code must be placed before the closing body tag if using a built-in JavaScript widget or loaded as late as possible if external (to ensure TPC and jQuery are loaded). In tpc.forms[0] make sure you are selecting the correct form, if there are multiple on the page and update the data-validation-msg AND parseDate format if you are using a different format.
Let me know if you have any trouble implementing the above,
Brady
TPC Web Developer
Last modified on 09 Feb 2022 14:02 by Brady Ward