Post by cepcemuh » Fri Oct 11, 2019 4:03 am

Hello professionals,
I need a little help... How can I disable the possibility a user to be able to add special characters in Shipping address or payments address, or even in the whole checkout text fields? I will use MyPos for Payment gateway and if there is a special symbol in the fields they cannot proceed with the payment so I need to disable user to add ""$#!№ and the other special symbols... Thank you in advance.

New member

Posts

Joined
Sat Jan 21, 2017 5:15 pm

Post by rjcalifornia » Fri Oct 11, 2019 2:52 pm

cepcemuh wrote:
Fri Oct 11, 2019 4:03 am
Hello professionals,
I need a little help... How can I disable the possibility a user to be able to add special characters in Shipping address or payments address, or even in the whole checkout text fields? I will use MyPos for Payment gateway and if there is a special symbol in the fields they cannot proceed with the payment so I need to disable user to add ""$#!№ and the other special symbols... Thank you in advance.
You can try adding a javascript function, and use the keypress event, to either show a warning about special character or block it completely

Image
A2 Hosting features: Shared Turbo Boost, Managed Warp 1, Unmanaged Hyper 1, and Warp 2 Turbo


Active Member

Posts

Joined
Fri Sep 02, 2011 1:19 pm
Location - Worldwide

Post by cepcemuh » Fri Oct 11, 2019 2:54 pm

rjcalifornia wrote:
Fri Oct 11, 2019 2:52 pm
cepcemuh wrote:
Fri Oct 11, 2019 4:03 am
Hello professionals,
I need a little help... How can I disable the possibility a user to be able to add special characters in Shipping address or payments address, or even in the whole checkout text fields? I will use MyPos for Payment gateway and if there is a special symbol in the fields they cannot proceed with the payment so I need to disable user to add ""$#!№ and the other special symbols... Thank you in advance.
You can try adding a javascript function, and use the keypress event, to either show a warning about special character or block it completely
Thank you for the advice but I think it will be better with a validation but cannot find where is the validation in opencart files...

New member

Posts

Joined
Sat Jan 21, 2017 5:15 pm

Post by paulfeakins » Fri Oct 11, 2019 4:47 pm

cepcemuh wrote:
Fri Oct 11, 2019 4:03 am
Hello professionals,
I need a little help... How can I disable the possibility a user to be able to add special characters in Shipping address or payments address, or even in the whole checkout text fields? I will use MyPos for Payment gateway and if there is a special symbol in the fields they cannot proceed with the payment so I need to disable user to add ""$#!№ and the other special symbols... Thank you in advance.
Don't annoy the user, just run it though this before you send to the gateway:
https://stackoverflow.com/questions/141 ... m-a-string

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Guru Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by cepcemuh » Fri Oct 11, 2019 9:53 pm

paulfeakins wrote:
Fri Oct 11, 2019 4:47 pm
cepcemuh wrote:
Fri Oct 11, 2019 4:03 am
Hello professionals,
I need a little help... How can I disable the possibility a user to be able to add special characters in Shipping address or payments address, or even in the whole checkout text fields? I will use MyPos for Payment gateway and if there is a special symbol in the fields they cannot proceed with the payment so I need to disable user to add ""$#!№ and the other special symbols... Thank you in advance.
Don't annoy the user, just run it though this before you send to the gateway:
https://stackoverflow.com/questions/141 ... m-a-string
Yes, I saw this link in stackoverflow but I am asking for instructions here and help...

New member

Posts

Joined
Sat Jan 21, 2017 5:15 pm

Post by paulfeakins » Fri Oct 11, 2019 10:10 pm

cepcemuh wrote:
Fri Oct 11, 2019 9:53 pm
Yes, I saw this link in stackoverflow but I am asking for instructions here and help...
If you're not a programmer, probably post it as a paid job in Commercial Support.

You'll need to be modify the payment gateway itself which isn't a built-in one, so may be best done by a professional.

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Guru Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by rjcalifornia » Sun Oct 13, 2019 2:04 am

cepcemuh wrote:
Fri Oct 11, 2019 9:53 pm
paulfeakins wrote:
Fri Oct 11, 2019 4:47 pm
cepcemuh wrote:
Fri Oct 11, 2019 4:03 am
Hello professionals,
I need a little help... How can I disable the possibility a user to be able to add special characters in Shipping address or payments address, or even in the whole checkout text fields? I will use MyPos for Payment gateway and if there is a special symbol in the fields they cannot proceed with the payment so I need to disable user to add ""$#!№ and the other special symbols... Thank you in advance.
Don't annoy the user, just run it though this before you send to the gateway:
https://stackoverflow.com/questions/141 ... m-a-string
Yes, I saw this link in stackoverflow but I am asking for instructions here and help...
Here's an example on how to deal with special characters:
viewtopic.php?t=6600

Image
A2 Hosting features: Shared Turbo Boost, Managed Warp 1, Unmanaged Hyper 1, and Warp 2 Turbo


Active Member

Posts

Joined
Fri Sep 02, 2011 1:19 pm
Location - Worldwide

Post by cepcemuh » Sun Oct 13, 2019 3:33 am

rjcalifornia wrote:
Sun Oct 13, 2019 2:04 am
Here's an example on how to deal with special characters:
viewtopic.php?t=6600
Thank you very much, I reviewed and made some tests but with no success... :(

New member

Posts

Joined
Sat Jan 21, 2017 5:15 pm

Post by letxobnav » Sun Oct 13, 2019 12:35 pm

You can clean the fields in function create_post at catalog/controller/extension/payment/mypos_virtual.php

as example:

Code: Select all

$post['CustomerAddress'] = $order_info['payment_address_1'];
would become:

Code: Select all

$post['CustomerAddress'] = $this->noSpecialCharacters($order_info['payment_address_1']);
if you add that function to the class:

Code: Select all

private function noSpecialCharacters($str) {
    return preg_replace('/[^A-Za-z0-9\-]/', '', $str);
}
do the same for the other fields you wish to clean.

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan
Who is online

Users browsing this forum: Bing [Bot] and 264 guests