Hello every one, i need to achive that the field "phone number" only accept numbers and not alphabetical characters. all your help and references will be helpfull
Solved! Go to Solution.
You can use below shared workaround:
To validate number you can use validate-number in your module checkout_index_index.xml
<item name="telephone" xsi:type="array"> <item name="config" xsi:type="array"> <item name="tooltip" xsi:type="array"> <item name="description" xsi:type="string" translate="true">For delivery questions</item> </item> </item> <item name="validation" xsi:type="array"> <item name="min_text_length" xsi:type="number">10</item> <item name="max_text_length" xsi:type="number">10</item> <item name="validate-number" xsi:type="number">0</item> </item> </item>
OR
form should be like
<form class="form contact" action="<?php /* @escapeNotVerified */ echo $block->getFormAction(); ?>" id="contact-form" method="post" data-hasrequired="<?php /* @escapeNotVerified */ echo __('* Required Fields') ?>" data-mage-init='{"validation":{}}'>
now in input field use data-validate="{'validate-number':true}"
Your input would look like:
<input type="text" data-validate="{'validate-number':true}">
You can use below shared workaround:
To validate number you can use validate-number in your module checkout_index_index.xml
<item name="telephone" xsi:type="array"> <item name="config" xsi:type="array"> <item name="tooltip" xsi:type="array"> <item name="description" xsi:type="string" translate="true">For delivery questions</item> </item> </item> <item name="validation" xsi:type="array"> <item name="min_text_length" xsi:type="number">10</item> <item name="max_text_length" xsi:type="number">10</item> <item name="validate-number" xsi:type="number">0</item> </item> </item>
OR
form should be like
<form class="form contact" action="<?php /* @escapeNotVerified */ echo $block->getFormAction(); ?>" id="contact-form" method="post" data-hasrequired="<?php /* @escapeNotVerified */ echo __('* Required Fields') ?>" data-mage-init='{"validation":{}}'>
now in input field use data-validate="{'validate-number':true}"
Your input would look like:
<input type="text" data-validate="{'validate-number':true}">
should I edit the file and save it, with that will work?