Hi, I’m stydying the form component of suite 8 gpl and blocked during the use of datepicker.
The goal was to validate the choosen date with the year of the previous control. I used this code:
(the form will be attached to window later)
form_t = new dhx.Form(null, {
width: 500,
height: 630,
rows: [
{
id: "anno_verb",
type: "input",
label: "Anno Verbale",
inputType: "number",
placeholder: "Anno",
required: true,
min: 2016,
validation: function(value) {
return value <= 2100 && value > 2015
}
},
{
id: "data_verb",
type: "datepicker",
label: "Data Verbale",
placeholder: "dd/mm/yyyy",
dateFormat: "%d/%m/%Y",
weekStart: "monday",
required: true,
validation: function(value) {
year = form_t.getItem("anno_verb").getValue();
Vyear = value.split("/");
return parseInt(Vyear[2]) == year;
},
},
{
type: "spacer"
},
{
align: "between",
cols: [
{
type: "spacer",
},
{
type: "button",
text: "ANNULLA",
view: "link",
color: "primary",
size: "small",
css: "dhx_form-button",
id: "cancel"
},
{
type: "button",
text: "AGGIUNGI",
view: "flat",
color: "primary",
size: "small",
css: "dhx_form-button",
id: "addItem"
}
]
}
]
});
form_t.events.on("afterValidate", function (id, value, isValid) {
if (!isValid) {
dhx.alert(...);
}
});
Now, the validation rule on datepicker never activates.
I tried to paste the code in an example snippet and the result was the same.
I also forced → “return false;” in the function block.
Can you help me, please?