• 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: Feature / PHP Code request: Trim fields on save

Feature / PHP Code request: Trim fields on save 9 years 7 months ago #32477

  • patrick.jackson
  • patrick.jackson's Avatar
  • OFFLINE
  • Junior Boarder
  • Joomla Consultant, Melbourne Australia
  • Posts: 22
  • Thank you received: 4
For some reason I'm encountering a lot of users with a tendency to add spaces at the end of their data entry.

Is there a simple way to process the form on submit and trim each field to get rid of the extra white spaces?

I would assume a PHP script to loop through the components on submit placed in the "Script called on form process" area would be the starting point, but just need to know what the for loop needs to look like.
Joomla Consultant & Hosting Provider
Melbourne Australia
Last Edit: 9 years 7 months ago by patrick.jackson.
The administrator has disabled public write access.

Feature / PHP Code request: Trim fields on save 9 years 7 months ago #32483

  • cosmin.cristea
  • cosmin.cristea's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 756
  • Thank you received: 144
Hello,

Note that this is something on top of my head and you should test this thoroughly before using it on your live website
foreach($_POST['form'] as $field => $value){
// you need to check if the form value is a string
	if (is_string($value)){
		$_POST['form'][$field] = trim($value);
	} else {
// and if not, you should skip it (checkboxes, radios have array of values)
		continue;
	}
}
My help is not official customer support. To receive your support, submit a ticket by clicking here
The administrator has disabled public write access.
The following user(s) said Thank You: mark.hobbs

Feature / PHP Code request: Trim fields on save 6 years 1 month ago #38934

I have a form with over 100 fields. Users are always adding extra spaces, especially in their name fields. I was thinking, "There should be a TRIM function in RSForm!"

I searched here and found this elegant solution. THANK YOU!

Mark
The administrator has disabled public write access.
  • 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!