0

I have to create a validation for the telephone inputs in Magento Admin. I need to set a min of characters like 8 and a max of 15. I'm currently using 2.2.8 version.

I tried to set the validation by admin using telephone attribute, but it didn't work. It inserts a class for validation but doesn't validate at all.

Thanks!

5
  • do you want this validation in system.xml file or in custom form?
    – Mohit Rane
    Aug 2, 2019 at 4:46
  • Hi @MohitRane, I want it for the new customer form and billing and shipping form inside the admin, but I don't even know where to look. =( Aug 12, 2019 at 3:24
  • do you want this change in custom module functionality or you to want to change in Magento's default functionality?
    – Mohit Rane
    Aug 12, 2019 at 4:30
  • Hey @MohitRane, I want to change in Magento's default functionality. Aug 12, 2019 at 22:29
  • can you share the screenshot of where you want this validation to make sure we're talking about the same thing?
    – Mohit Rane
    Aug 13, 2019 at 5:02

1 Answer 1

1

Put the following code inside the telephone number block in your layout file

 <item name="validation" xsi:type="array">
    <item name="min_text_length" xsi:type="number">8</item>
    <item name="max_text_length" xsi:type="number">15</item>
    <item name="validate-number" xsi:type="number">0</item>
 </item>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.