diff --git a/controllers/front/AddressController.php b/controllers/front/AddressController.php index eb17888ce..f8575864b 100644 --- a/controllers/front/AddressController.php +++ b/controllers/front/AddressController.php @@ -44,6 +44,7 @@ class AddressControllerCore extends FrontController { parent::setMedia(); $this->addJS(_THEME_JS_DIR_.'tools/statesManagement.js'); + $this->addJS(_PS_JS_DIR_.'validate.js'); } /** @@ -268,6 +269,7 @@ class AddressControllerCore extends FrontController // Assign common vars $this->context->smarty->assign(array( + 'address_validation' => Address::$definition['fields'], 'one_phone_at_least' => (int)Configuration::get('PS_ONE_PHONE_AT_LEAST'), 'onr_phone_at_least' => (int)Configuration::get('PS_ONE_PHONE_AT_LEAST'), //retro compat 'ajaxurl' => _MODULE_DIR_, @@ -339,8 +341,8 @@ class AddressControllerCore extends FrontController protected function assignAddressFormat() { $id_country = is_null($this->_address)? 0 : (int)$this->_address->id_country; - $dlv_adr_fields = AddressFormat::getOrderedAddressFields($id_country, true, true); - $this->context->smarty->assign('ordered_adr_fields', $dlv_adr_fields); + $ordered_adr_fields = AddressFormat::getOrderedAddressFields($id_country, true, true); + $this->context->smarty->assign('ordered_adr_fields', $ordered_adr_fields); } /** diff --git a/js/validate.js b/js/validate.js new file mode 100644 index 000000000..766d319ed --- /dev/null +++ b/js/validate.js @@ -0,0 +1,72 @@ +/* +* 2007-2013 PrestaShop +* +* NOTICE OF LICENSE +* +* This source file is subject to the Open Software License (OSL 3.0) +* that is bundled with this package in the file LICENSE.txt. +* It is also available through the world-wide-web at this URL: +* http://opensource.org/licenses/osl-3.0.php +* If you did not receive a copy of the license and are unable to +* obtain it through the world-wide-web, please send an email +* to license@prestashop.com so we can send you a copy immediately. +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade PrestaShop to newer +* versions in the future. If you wish to customize PrestaShop for your +* needs please refer to http://www.prestashop.com for more information. +* +* @author PrestaShop SA +* @copyright 2007-2013 PrestaShop SA +* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ + +function validate_isName(s) +{ + var reg = /^[^0-9!<>,;?=+()@#"°{}_$%:]+$/; + return reg.test(s); +} + +function validate_isGenericName(s) +{ + var reg = /^[^<>={}]+$/; + return reg.test(s); +} + +function validate_isAddress(s) +{ + var reg = /^[^!<>?=+@{}_$%]+$/; + return reg.test(s); +} + +function validate_isPostCode(s) +{ + var reg = /^[a-z 0-9-]+$/i; + return reg.test(s); +} + +function validate_isCityName(s) +{ + var reg = /^[^!<>;?=+@#"°{}_$%]+$/; + return reg.test(s); +} + +function validate_isMessage(s) +{ + var reg = /^[^<>{}]+$/; + return reg.test(s); +} + +function validate_isPhoneNumber(s) +{ + var reg = /^[+0-9. ()-]+$/; + return reg.test(s); +} + +function validate_isDniLite(s) +{ + var reg = /^[0-9a-z-.]{1,16}$/i; + return reg.test(s); +} diff --git a/themes/default/address.tpl b/themes/default/address.tpl index 95159c25b..263d3465e 100644 --- a/themes/default/address.tpl +++ b/themes/default/address.tpl @@ -100,7 +100,7 @@ $(function(){ldelim} {if $field_name eq 'company'}

- +

{/if} {if $field_name eq 'vat_number'} @@ -108,7 +108,7 @@ $(function(){ldelim}

- +

@@ -116,38 +116,43 @@ $(function(){ldelim} {if $field_name eq 'firstname'}

- +

{/if} {if $field_name eq 'lastname'}

- +

{/if} {if $field_name eq 'address1'}

- +

{/if} {if $field_name eq 'address2'}

- +

{/if} {if $field_name eq 'postcode'} {assign var="postCodeExist" value="true"}

- +

{/if} {if $field_name eq 'city'}

- +

{* if customer hasn't update his layout address, country has to be verified @@ -199,7 +204,8 @@ $(function(){ldelim} {if $postCodeExist eq "false"} {/if} {if $stateExist eq "false"} @@ -212,22 +218,25 @@ $(function(){ldelim} {/if}

- +

{if isset($one_phone_at_least) && $one_phone_at_least}

{l s='You must register at least one phone number.'}

{/if}

- +

- +

- +