1

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

2 Answers 2

3

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.

3
  • Do you know what file I would find this code in? Thank you !!!!
    – Tracer88
    Aug 5, 2014 at 8:47
  • Nevermind, I found the file and it worked. Thank you very much!!!!!
    – Tracer88
    Aug 5, 2014 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! Aug 5, 2014 at 12:38
0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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