Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Limit Address Field Length
 
ukgoods
Member
 
Avatar
Total Posts:  44
Joined:  2008-07-20
 

I have a recurring problem. 

My shipping system requires a maximum address length of 30.  Magento allows the user to put in much more than this.

Could someone point me to the files that need to be changed for both the billing and shipping addresses?

Thanks,

Donna

 
Magento Community Magento Community
Magento Community
Magento Community
 
Rastgoo
Member
 
Avatar
Total Posts:  49
Joined:  2009-04-03
Ottawa, ON
 

I need this too. have you found any solution to it?

 
Magento Community Magento Community
Magento Community
Magento Community
 
ukgoods
Member
 
Avatar
Total Posts:  44
Joined:  2008-07-20
 

I still can’t find which file to change for this. 

Anyone?  Please help!

Thanks,

Donna

 
Magento Community Magento Community
Magento Community
Magento Community
 
Rastgoo
Member
 
Avatar
Total Posts:  49
Joined:  2009-04-03
Ottawa, ON
 

I’m trying to change

form.phtml
register.phtml

in app\design\frontend\default\default\template\customer\form

I hope something will happen.

This is the html code: maxlength="#"

 
Magento Community Magento Community
Magento Community
Magento Community
 
Rastgoo
Member
 
Avatar
Total Posts:  49
Joined:  2009-04-03
Ottawa, ON
 

Ok Case Solved,

Wasn’t that hard actually.

There are couple of files to be edited. each of them are located at different place.
just think of those places that you have address fields and go for them:

first: in customer account panel: so go to:

/app/design/frontend/default/default/template/customer/address

target file is: edit.phtml

line 71 and 75 for me. right before /></li> paste: maxlength="30" so it will look like this:  maxlength="30" /></li>

Second: in the checkout page: mine in a single page checkout:

/app/design/frontend/default/default/template/checkout/onepage

2files are here: billing.phtml $ shipping.phtml

at the end of lines 48 and 50 right before /></li> paste: maxlength="30" so it will look like this:  maxlength="30" /></li>

3rd is at admin, I have no time to find it now so I just post this and will continue after.
refresh cache and check what you have done. wink

 
Magento Community Magento Community
Magento Community
Magento Community
 
ukgoods
Member
 
Avatar
Total Posts:  44
Joined:  2008-07-20
 

Works like a charm! 

Thanks,

Donna

 
Magento Community Magento Community
Magento Community
Magento Community
 
Rastgoo
Member
 
Avatar
Total Posts:  49
Joined:  2009-04-03
Ottawa, ON
 

YW

Were you successful in the backend side? in admin I mean.

I cannot find the right file!

 
Magento Community Magento Community
Magento Community
Magento Community
 
ukgoods
Member
 
Avatar
Total Posts:  44
Joined:  2008-07-20
 

No, I haven’t tried finding that yet.  I had tried the billing and shipping files before but forgot to refresh cache.  To be frank, I am more worried about the front end.  I will work on the backend on Monday.

 
Magento Community Magento Community
Magento Community
Magento Community
 
eatblueorange
Member
 
Avatar
Total Posts:  34
Joined:  2010-03-22
Philippines
 

for the admin just put maxlength

example

$fieldset->addField(’title’, ‘text’, array(
‘label’ => Mage::helper(’custom_module’)->__(’Title’),
‘class’ => ‘required-entry’,
‘maxlength’ => 60,
‘required’ => true,
‘name’ => ‘title’,
));

 
Magento Community Magento Community
Magento Community
Magento Community
 
MageAction
Sr. Member
 
Avatar
Total Posts:  89
Joined:  2008-05-28
France
 

If you have the onestepcheckout module:

go in

/app/design/frontend/base/default/template/onestepcheckout/billing_fields.phtml

add this small javascript in the top of the page:

<script type="text/javascript\">
function limitlength(obj, length){
var maxlength=length
if (obj.value.length>maxlength)
obj.value=obj.value.substring(0, maxlength)
}
</script>

then add the onkeyup="return limitlength(this, 30)” in the address field

$addressFields .= ‘<input type="text" title=“‘.$this->__(’Street Address ‘.$_i).’” name="billing[street][]" id="billing:street’.$_i.‘“ onkeyup="return limitlength(this, 30)” value="’.$this->htmlEscape($this->getStreet($_i)).‘“ class=“‘.(($_i == 1)? ‘required-entry ‘ : ‘’).’input-text onestepcheckout-address-line” />’;
$addressFields .= (($_i != $this->helper(’customer/address’)->getStreetLines()) ? ‘<br/>’: ‘’);

 
Magento Community Magento Community
Magento Community
Magento Community
 
MagespotCrew
Jr. Member
 
Avatar
Total Posts:  2
Joined:  2013-09-17
 

If you need to limit the customer address line lenght (no matter checkout process or in the customer account, when the customer submit a new address) is a Magento extension: http://magespot.com/address-line-lenght-limit.html
Also support Multiaddress checkouts, if customer use different billing and shipping addresses

 
Magento Community Magento Community
Magento Community
Magento Community
 
Monty_iLM
Guru
 
Total Posts:  450
Joined:  2013-11-05
 

Hi,

You can check this thread http://www.jimcode.org/2011/03/magento-limit-address-fields-30-characters/

Hope this will help you!!

Thanks

Monty
iLoveMage

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top