ikran Posted June 14, 2022 Share Posted June 14, 2022 Good morning, how is it possible to force the insertion in uppercase on the input form of the vat number? If customers do not write in capital letters, the vat number is not recognized as valid by the module for validating the vat number through vies. Link to comment Share on other sites More sharing options...
okom3pom Posted June 14, 2022 Share Posted June 14, 2022 You can try : https://www.the-art-of-web.com/html/input-field-uppercase/ I can't post the code directly. Link to comment Share on other sites More sharing options...
ikran Posted June 14, 2022 Author Share Posted June 14, 2022 can you tell me the path where the file to edit is located? Link to comment Share on other sites More sharing options...
okom3pom Posted June 14, 2022 Share Posted June 14, 2022 You can also do this with css Edit /themes/your_theme/assets/css/custom.css Add : #field-vat_number { text-transform: uppercase; } 1 Link to comment Share on other sites More sharing options...
ikran Posted June 14, 2022 Author Share Posted June 14, 2022 Hello, I tried with css, but unfortunately it does not work as the vat number in the database is stored in lowercase and consequently the validation does not work. Link to comment Share on other sites More sharing options...
okom3pom Posted June 14, 2022 Share Posted June 14, 2022 You need to update your VAT NUMBER in your data base ? Or it's for new customer ? Link to comment Share on other sites More sharing options...
ikran Posted June 14, 2022 Author Share Posted June 14, 2022 For new customers who register and enter the vat number with lowercase letters. I've already tried adding the text-transform statement to the css: uppercase; doing so, however, I see the text maiscolo only on screen, but it is stored in lowercase in the db. So I would like to understand how to make sure that the vat number is stored in all letters. I would like to try to use javascript like this: <input type = "text" onkeyup = "this.value = this.value.toUpperCase ();"> but I don't know the path of the file that I have to modify ... Link to comment Share on other sites More sharing options...
okom3pom Posted June 14, 2022 Share Posted June 14, 2022 The best way is to use custom.js because the html is generate by php and need an override. Try this : $( function() { $('#field-vat_number').change(function() { var value = $('#field-vat_number').val(); $('#field-vat_number').val(value.toUpperCase()); }); }); Link to comment Share on other sites More sharing options...
lordignus Posted June 14, 2022 Share Posted June 14, 2022 (edited) Depends on your PS version, but I've just tried this on PS 1.7.80 and it works with by creating an override for the Address class. <?php class Address extends AddressCore { public function __construct($id_address = null, $id_lang = null){ parent::__construct($id_address, $id_lang); if($this->vat_number && ($this->vat_number != strtoupper($this->vat_number))){ $this->vat_number = strtoupper($this->vat_number); $this->update(); } } } I threw in the update() in case your module works by retrieving the vat_number column through the database rather than by using the Address class. Edited June 14, 2022 by lordignus (see edit history) Link to comment Share on other sites More sharing options...
Knowband Plugins Posted June 15, 2022 Share Posted June 15, 2022 Kindly add the below code in /themes/classic/theme.js $(function() { $('#field-vat_number').keyup(function() { this.value = this.value.toLocaleUpperCase(); }); }); It will automatically convert the inputted lower case character to uppercase. Link to comment Share on other sites More sharing options...
Mediacom87 Posted June 15, 2022 Share Posted June 15, 2022 Il y a 4 heures, Knowband Plugins a dit : Kindly add the below code in /themes/classic/theme.js Bad idea, we never touch this file, strictly never, since it is the result of the compilation of the original files before the theme is put into production. As it was perfectly explained by @okom3pom on PrestaShop 1.7 we use the custom.js file and for the style the customl.css file. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now