Jump to content

Taking Only Space The Address Field Is Submitting


Recommended Posts

Hi All, 

 

I am using prestashop 1.6+ and when I am giving a space in any of the address field like Name, Ph No, Mobile no etcpost-1098526-0-22752500-1454326924_thumb.jpg. all the fields are taking this and it is showing ok whereas I Have not given any character.

 

Need solution.

 

Thanks,

Santanu

Link to comment
Share on other sites

  • 1 month later...

Maybe it's too late, but hopefully it will be helpful.

You have to edit file /js/validate.js
At the end of that file you can see this code:

$(document).on('focusout', 'input.validate, textarea.validate', function() {
    validate_field(this);
});

Replace it by the following:

$(document).on('focusout', 'input.validate, textarea.validate', function() {
    // trim spaces
    $(this).val($(this).val().trim());
    validate_field(this);
});

Then you need to create an override of Address class (create or edit file /override/classes/Address.php)
Place there the following code:

<?php

class Address extends AddressCore
{
    /**
     * @see ObjectModel::validateController()
     */
    public function validateController($htmlentities = true)
    {
        // remove whitespaces from the beginning and end of a input data
        $_POST = array_map('trim', $_POST);

        return parent::validateController($htmlentities);
    }
}
  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...