Hi,
I would like to validate the dropdown list dataSource in resouces:
resources: [{
field: "ownerId",
title: "Patient",
validation: {
required: true
},
dataSource: patientList
}]
P/s: I have tried to added the attribute required="required" to the select, it validate OK, but i can't save to create new event, even i have picked one from the list.
7 Answers, 1 is accepted
This dojo provides an example of custom validation. I set up my own rule for the ownerId input (it has to be Charlie, which has value 3 in that example), and my own message for if the validation fails.
You will want to utilize a custom editor template for this, which gives you greater control and flexibility.
Custom editor template example
you could potentially create a validator on the built in pop up editor, but grabbing the fields to check validation on will be much more difficult.
If you just want to check if the field is populated, just add a required attribute, a data-required-msg attribute, and then:
$('#editorWrapper').kendoValidator();
Then just call validate() with that and it easily determines if the field has a value, and if not, prevents the user from continuing.
Tyler has already provided great examples for your scenario. I could add that you could also take reference to the built in validator in the scheduler and set custom validation rules and messages. Here are articles illustrating it:
https://docs.telerik.com/kendo-ui/controls/scheduling/scheduler/how-to/validation/getting-reference-to-the-validator
https://docs.telerik.com/kendo-ui/api/javascript/ui/validator
Regards,
Joana
Progress Telerik
I added required attribute and message to the dropdown list and added event onchange, and remove the attr require if the dropdown list has value (when user pick one).
I'll check your solution to build custom validator and message.
Let us know if you have any other question regarding the implementation of custom validator.
Regards,
Joana
Progress Telerik
Hi Joan,
I have tried to implement kendo validator, but seems it doesn't work:
Please check it on: http://dojo.telerik.com/@n2lose/ohagI
As i have checked in the DOM, i saw select roomId has attribute require and title, when i click on save, it validated but don't show the message?
Could you tell me what's wrong? Thanks
Regards,
Lam
You need the 'name' attribute on your elements in order to see the validator message for your custom fields.
This Dojo has your scheduler working and I can see validation messages for the title and roomId fields. All that was changed as adding a
name: roomId
to your roomId field in the schema setup.