Take the 2-minute tour ×
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It's 100% free, no registration required.

I am getting a "This is a required field" error during customer checkout when the customer enters a phone number with hyphens are parenthesis. When special characters are not used it works without issues. Anyone have a solution for this problem?

Thanks!

enter image description here

share|improve this question

2 Answers 2

up vote 2 down vote accepted

It looks like the Telephone field is actually using a number input type:

<input type="number" name="billing[telephone]" value="" title="Telephone" class="input-text  required-entry form-control validation-failed" id="billing:telephone">

The number type only supports floating-point numbers - an input value like 555-555-5555 isn't a proper number, so the browser clears out the field right before Magento validates the input. The value is blank, so it displays the "required field" validation message.

Try using type="tel" or type="text" instead, and that should resolve your issue.

share|improve this answer
    
Do you know what file I would find this code in? Thank you !!!! –  Tracer88 Aug 5 at 8:47
    
Nevermind, I found the file and it worked. Thank you very much!!!!! –  Tracer88 Aug 5 at 9:11
    
I'm glad I could help! If you could mark this answer as Accepted (click the check mark) I'd greatly appreciate it! –  Colin O'Dell Aug 5 at 12:38

The validations are placed in js/prototype/validation.js file

The exact validation for phone is as:

['validate-phoneStrict', 'Please enter a valid phone number. For example (123) 456-7890 or 123-456-7890.', function(v) {
                return Validation.get('IsEmpty').test(v) || /^(\()?\d{3}(\))?(-|\s)?\d{3}(-|\s)\d{4}$/.test(v);
            }],

Try using phoneStrict validation.

I am checking on magento 1.9 and 1.8 version

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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