Hi, I have a problem. I have created a custom validation attribute, created the adapter, provider, registered it and wrote the javascript code. I can see everything load, but the java script code is not called. I think it is because the adapter writes attributes to the HTML generated and when using a devextreme form, the HTML is not generated in the traditional way. According to this article Client Side Validation - DevExpress you guys support the "custom" attribute. How do I get my custom attribute to execute client side validation with a devextreme form? Thanks.
Form - Custom Validation doesn't work
Answers approved by DevExpress Support
Hello,
I discussed this question with our developers. It's necessary to define the ValidationGroup widget as in the Validation demo. I created a sample project based on the Implement a Custom Validation Rule article demonstrating how to use the custom validation rule. Please review the attachment and let me know if this sample helps.
Regards,
Vova
I was missing the "-custom-*" when adding the attributes to the HTML. This now works. I do have another question though. How can I force validation? The problem I have is this: I am using custom attributes to do validation. I have 4 dates in the form. The first date must be before any of the other dates. The problem is that it is the first date listed on the form, so when it goes to validate the first time, the other dates aren't filled in and it validates incorrectly. How can I call it's validate after all of the other dates have filled in, so that it properly shows me the correct validation message? I tried manually calling it's validate method, but I can't seem to find a valid method. Here is one approach I took:
JavaScript$("#formPool").dxForm("instance").getEditor("IssueDate").validate(); //No Method called validate
$("#formPool").dxForm("instance").getEditor("IssueDate").component.validate(); //No Method called validate
Hello,
I've created a separate ticket on your behalf (T619968: How to manually call validation). It has been placed in our processing queue and will be answered shortly.
Hi,
A custom validation rule should be automatically checked after an editor value is changed. There shouldn't be any difference between solutions for a stand-alone editor and the Form widget. We would need to review your code to see what goes wrong. Could you please post your Form and Data Annotation attribute code files for further examination? We'll do our best to put you on the right track.
Can you give me an example of a Core 2 Razor pages app, using a DevExtreme form, with a custom attribute used for validation? Perhaps I am just missing a step?
Hello,
I reproduced the described issue while creating an example. I need to discuss this issue with our developers. We will update this ticket as soon as we have any news.
Regards,
Vova