How to create custom Validation for UI Component Form? I want to create Validation for maximum character, not for max-word which is already available in Magento 2. if any body knows please share the procedure.Thanks
-
Can you please share your code where you want to add?– Rohan HapaniAug 1, 2018 at 18:02
-
@RohanHapani <item name="validation" xsi:type="array"> <item name="required-entry" xsi:type="boolean">true</item> <item name="validate-length" xsi:type="boolean">true</item> Here i want to limit my character. i want that form sould only accept 250 character . </item>– sudo55Aug 1, 2018 at 18:13
-
please check my answer and let me know if any issue.– Rohan HapaniAug 1, 2018 at 18:42
1 Answer
Try to do like this :
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item>
<item name="max_text_length" xsi:type="number">250</item>
</item>
clean cache and check it.
-
thank you, its working. do you know how i can create my own validation?– sudo55Aug 1, 2018 at 18:50
-
1Happy Coding !! :) You can accept this answer for helpful to other developer. Aug 1, 2018 at 18:51
-
Yes. You can create custom validation by js. You can take reference from here. inchoo.net/magento-2/build-your-custom-form-validation-rule Aug 1, 2018 at 18:53
-
Now, You can Re-accept answer if this answer is useful in this above question ;) Aug 1, 2018 at 19:10
-
1Yes. I can give answer. But, you can create new question for that. Because, what's your question that I already gave answer and it's 100% working as you said. So, you can accept it. It's better if you create new question. So, for other user it's easy to get answer of this question :) Aug 2, 2018 at 17:59