How to add mobile number validation in magento

No comments
To validate a mobile number in checkout page or in any other templates, find the mobile number field and add below classes in the class attribute. By using below classes user can only enter 10 digits. Other values, for example, alphanumeric, strings are not allowed.

validate-digits maximum-length-10 minimum-length-10
For example:
<input type="text" id="mobile" name="mobile" title="Mobile" class="input-text required-entry validate-digits maximum-length-10 minimum-length-10">
Here are the uses of the above classes:
validate-length: Default class.It allows digits only.
maximum-length-10: Magento default class. Checks the maximum length of input, shows error if the length is greater than 10.
minimum-length-10: Magento default class. Checks the minimum length of input, shows error if the length is less than 10.

No comments :

Post a Comment