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
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

rconstantine - March 24, 2008 - 06:07

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

ron_s - April 15, 2008 - 06:31

Sure ... in cck_address.module in the cck_address_validate_address_fields function, 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

DanielTheViking - April 20, 2008 - 22:20
Title:Error Validation on Apt/Suite Number Field» Spaces not allowed in Apt/Suite Number Field

#4

rconstantine - April 22, 2008 - 01:47
Status:active» reviewed & tested by the community

Thanks for that. That is correct.

#5

New Zeal - July 23, 2009 - 03:08
Status:reviewed & tested by the community» closed

Issue fixed.

 
 

Drupal is a registered trademark of Dries Buytaert.