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 Hapani– Rohan Hapani2018-08-01 18:02:59 +00:00Commented Aug 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>sudo55– sudo552018-08-01 18:13:23 +00:00Commented Aug 1, 2018 at 18:13
- please check my answer and let me know if any issue.Rohan Hapani– Rohan Hapani2018-08-01 18:42:29 +00:00Commented Aug 1, 2018 at 18:42
Add a comment |
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?sudo55– sudo552018-08-01 18:50:38 +00:00Commented Aug 1, 2018 at 18:50
- 1Happy Coding !! :) You can accept this answer for helpful to other developer.Rohan Hapani– Rohan Hapani2018-08-01 18:51:39 +00:00Commented 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-ruleRohan Hapani– Rohan Hapani2018-08-01 18:53:26 +00:00Commented Aug 1, 2018 at 18:53
- Now, You can Re-accept answer if this answer is useful in this above question ;)Rohan Hapani– Rohan Hapani2018-08-01 19:10:26 +00:00Commented 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 :)Rohan Hapani– Rohan Hapani2018-08-02 17:59:52 +00:00Commented Aug 2, 2018 at 17:59