How to Change Telephone Field Input Type Validation on Checkout Onepage

checkoutformsvalidation

How can I change telephone field input type validation on check out onepage ?

Currently it takes input numeric with no space. I want to change it space with numbers

As an example,

current input format is: 1234567899999

But when i try this input format: 123 45468 99999

it is not working. What should I do to format this number?

Best Answer

Magento uses Prototype library to manage form validation of input fields. This comes in handy, because all you need to do when writing custom form is to assign a valid class names to your input fields, and pass the form id to VarienForm object.

you need add css class validate-phoneStrict at field which will do this type validation. you need to remove validate-number etc validation

You need see js field validation at js\prototype\validation.js

        <input type="tel" name="billing[telephone]" 
    value="<?php echo $this->escapeHtml($this->getAddress()->getTelephone()) ?>"
     title="<?php echo $this->__('Telephone') ?>" class="validate-phoneStrict
     input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('telephone') ?>"
 id="billing:telephone" />

and you can also do below format:

(123) 456-7890 or 123-456-7890
Related Topic