I've check and test the opencart system I notice that it doesnt validate numbers...Also any idea on how I could separate
Telephone number in 3 parts
like 1st text box "Country Code"
2nd textbox "Area Code"
3rd "Telephone Number"
also Where Could I find the REGEX of the telephone so it would accept numbers only...
Thanks
Telephone number in 3 parts
like 1st text box "Country Code"
2nd textbox "Area Code"
3rd "Telephone Number"
also Where Could I find the REGEX of the telephone so it would accept numbers only...
Thanks
In the associated controller there will be a function called validate(). You can check in this function whether the telephone number preg_match("\d+") or the regex you require and return error if not. Then you will have your telephone validation.
Documentation: OpenCart User Guide
Mods: Total Import PRO | CSV Import PRO | Ecom Tracking | Any Feed | Autosuggest | OpenCart CDN
For example, the account creation page: catalog/controller/account/create.php
You will see in that file a line that says this:
That is checking that the telephone given is between 3 and 32 characters long. You could make it also check that it was only digits like this:
You can do this same in the controllers on any other pages - eg the checkout pages.
You will see in that file a line that says this:
Code: Select all
if ((strlen(utf8_decode($this->request->post['telephone'])) < 3) || (strlen(utf8_decode($this->request->post['telephone'])) > 32)) {
$this->error['telephone'] = $this->language->get('error_telephone');
}
Code: Select all
if ((strlen(utf8_decode($this->request->post['telephone'])) < 3) || (strlen(utf8_decode($this->request->post['telephone'])) > 32) || preg_match('/[^\d]/is', $this->request->post['telephone'])) {
$this->error['telephone'] = $this->language->get('error_telephone');
}
Documentation: OpenCart User Guide
Mods: Total Import PRO | CSV Import PRO | Ecom Tracking | Any Feed | Autosuggest | OpenCart CDN
It is very difficult and often counterproductive to effectively validate a telephone number.
Country Codes, City Codes and telephone numbers vary in length country to country, and often also within a country. Country Codes can be 1, 2 or 3 digits long and the entire telephone number, including the Country Code, may be not more than 15 digits long.
Also, be careful about limiting the entry in the telephone number field to digits only. You will deprive someone behind a switchboard of the ability to enter an extension number, which may prevent that customer from receiving your shipment.
t_mask17, what problem are you trying to solve or correct by asking for this advice?
Country Codes, City Codes and telephone numbers vary in length country to country, and often also within a country. Country Codes can be 1, 2 or 3 digits long and the entire telephone number, including the Country Code, may be not more than 15 digits long.
Also, be careful about limiting the entry in the telephone number field to digits only. You will deprive someone behind a switchboard of the ability to enter an extension number, which may prevent that customer from receiving your shipment.
t_mask17, what problem are you trying to solve or correct by asking for this advice?
Please use proper English at all times, so that all members may understand you.
Who is online
Users browsing this forum: No registered users and 8 guests