Spaces not allowed in Apt/Suite Number Field
ron_s - March 21, 2008 - 17:02
| Project: | Address field for CCK |
| Version: | 5.x-2.1 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
I entered in the Apt/Suite number field the value Ste 190 and received the following error message:
Illegal value for Address's Apt/Suite Number field. Only letters, numbers, ' and - are valid. No other special characters allowed.
Hmmm last time I checked Ste are letters. :) I took a look at the code in cck_address.module and looks like the same RegExp is being used for street address and apt/suite, so not sure why it would be handled differently? Any suggestions? Thanks in advance for your help.

#1
I think this is a duplicate issue where I forgot to allow spaces in the regex. Oops again. Will be fixed in the next release, but og_forum is ahead of this in line and there are some big features/fixes involved with that. You could modify the regex to allow spaces and then post your code here for others to use.
#2
Sure ... in cck_address.module in the
cck_address_validate_address_fieldsfunction, find the following line (around line 996):if (($item['apt'] != '') && (!preg_match("/^[\.\'\-[:alpha:]0-9\/]+$/", $item['apt']))) {and change it to as follows:
if (($item['apt'] != '') && (!preg_match("/^[\.\'\-[:alpha:]0-9\/\s]+$/", $item['apt']))) {This will allow spaces to be accepted.
#3
#4
Thanks for that. That is correct.
#5
Issue fixed.