• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: prevent spaces and hyphens in field

prevent spaces and hyphens in field 5 years 1 month ago #39922

  • patrick75
  • patrick75's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 3
  • Thank you received: 1
I am using SMS to send a notification to user entering data into a a contact and booking form.

Currently I have a dropdown for the country code and one for a three digit prefix. The reason I have the prefix dropdown is because in SMS I use placeholders to enter the mobile phone number.
i.e. {countryCode:value}(prefix:value}{phone:value}
I've done it this way because SMSGlobal cannot accept a number such as 6402712345678. where 64 is the country code and 027 is the prefix. The correct number should be 642712345678.

My question: is it possible to strip the '0' from 02712345678 and prevent the use of a hyphen and spaces in a text field without the need for the prefix dropdown.

I have seen this work on other website. Hope we can make this work on RSForm Pro.

This is hugely important as I also do not wish to find out and list every mobile carrier prefix around the world resulting in a conditional field for every country, as well.

Additionally this must with with AJAX. Our customers complain about validation messages and having to re-enter data several times until they get it right.
The administrator has disabled public write access.

prevent spaces and hyphens in field 5 years 1 month ago #39925

  • adrianp
  • adrianp's Avatar
  • OFFLINE
  • RSJoomla! Official Staff
  • Posts: 631
  • Thank you received: 146
Hello,

You can try one of the following approaches:

- create your own custom validation rule and use it on your phone number field (this would be normally applied on your AJAX validation, just like any other validation when the AJAX validation is enabled in your form).

- or use a hidden field and a PHP script (while editing the form > Form Properties > PHP Scripts > "Scripts Called On Form Process" area) to strip zeroes, spaces and hyphens from your phone number value while inserting this stripped variation within the hidden field's value. Thus, you can use the hidden field placeholder instead within your form's SMS configuration tab.
This is not official customer support. To receive your support, submit a support ticket here.
The administrator has disabled public write access.

prevent spaces and hyphens in field 5 years 1 month ago #39928

  • patrick75
  • patrick75's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 3
  • Thank you received: 1
Thank you for pointing me in the right direction.

For anyone else needing this solution...
Step 1 - create hidden field. name it 'sms'
Step 2 - PHP on Form Process
$x = $_POST ;
$rm = [" ", "-",];
$str1 = str_replace($rm, "", ltrim($x, '0'));
$_POST = $str1;
Step 3 - SMS To Number = {countryCode:value}{sms:value}

This method assumes you have text field named 'phoneNumber' and dropdown named 'countryCode ' in the following format...
Items
64|New Zealand (+64)
61|Australia (+61)
33|France (+33)
...
The administrator has disabled public write access.
The following user(s) said Thank You: joeausti
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!