0

People visiting our store enter telephone numbers in all formats including prefixing 0, 00, +(countrycode).

By default(and strangely) Opencart registeration field for telephone allows alphanumeric values upto 32 characters in length.

Could anyone guide how can I go about setting the length to 10 digits on registeration and checkout pages.

ASG
  • 31
  • 1
  • 7

2 Answers2

0

You need to edit your register controller File. You can find your register controller file here catalog/controller/account/register.php

Then in this file you can see below function in this file.

protected function validate() {

You can change below code :

if ((utf8_strlen($this->request->post['telephone']) < 3) || (utf8_strlen($this->request->post['telephone']) > 32)) {

To

if ((utf8_strlen($this->request->post['telephone']) < 3) || (utf8_strlen($this->request->post['telephone']) > 10)) {

You need to change validation message as well. Just open this file : catalog/language/english/account/register.php

$_['error_telephone']      = 'Telephone must be between 3 and 32 characters!';

To

$_['error_telephone']      = 'Telephone must be between 3 and 10 characters!';
Hardik Solanki
  • 3,153
  • 1
  • 17
  • 28
0

I have the same code in my website, what it's supposed to do is just accept numbers but this code allows alphabets to be written as well.

YakovL
  • 7,557
  • 12
  • 62
  • 102