cqpbert Posted October 12, 2023 Share Posted October 12, 2023 where can I put an input validation for the Zip code? At least twice I have received orders with the persons email address in the zip code field. Now I get that the customer has entered this wrong, but seems like we should at least check there is no @ in the zipcode? Quote Link to comment Share on other sites More sharing options...
bsmither Posted October 12, 2023 Share Posted October 12, 2023 Since you are calling this a "ZIP Code", may we assume your only country of delivery is the USA? If not, a different test must be developed. Quote Link to comment Share on other sites More sharing options...
cqpbert Posted October 12, 2023 Author Share Posted October 12, 2023 I ship international as well. Thats why I was thinking about looking for the @, or really any non letter/number? Quote Link to comment Share on other sites More sharing options...
bsmither Posted October 12, 2023 Share Posted October 12, 2023 The (jQuery-based) Validator code that the Foundation skin uses has an 'additional package' that can be incorporated. This package has several postcode tests, as well as a 'numbers, letters, and underscore only' test. I will be experimenting with that soon. Quote Link to comment Share on other sites More sharing options...
bsmither Posted October 12, 2023 Share Posted October 12, 2023 Go here and download the jquery.validator.additional-methods.js file: https://github.com/jquery-validation/jquery-validation/tree/1.19.5/dist Place the file in the skin's /js/vendor/ folder. Edit the skin template element.js_foot.php file: Find: {assign var=js_foot value=[ 'skins/{$SKIN_FOLDER}/js/vendor/jquery.rating.min.js', 'skins/{$SKIN_FOLDER}/js/vendor/jquery.validate.js', Add after: 'skins/{$SKIN_FOLDER}/js/vendor/jquery.validator.additional-methods.js', Edit the skin's javascript 3.cubecart.validate.js file: Near line 355, find: $("#addressbook_form").validate({ rules: { Then find: postcode: { required: true } Change to: postcode: { alphanumeric: true, required: true } Near line 214, find: $("#checkout_form").validate({ rules: { Then find: 'billing[postcode]': { required: true }, Change to: 'billing[postcode]': { alphanumeric: true, required: true }, Then find: 'delivery[postcode]': { required: true }, Change to: 'delivery[postcode]': { alphanumeric: true, required: true }, Log in to the storefront and view your addressbook. Edit an existing address. Change the postcode to have a character other than a letter, number, or underscore (not dashes or spaces). When the Save button is clicked, there should appear a red banner saying to use only certain characters. The additional methods file include rules for various postal code formats: CA, NL, IT, UK, US. But I have yet to learn how to get the validator to cycle through them until one returns true, or to positively choose which one to use. Quote Link to comment Share on other sites More sharing options...
cqpbert Posted October 13, 2023 Author Share Posted October 13, 2023 Thank you very much - this will be weekend home work for me. Quote Link to comment Share on other sites More sharing options...
cqpbert Posted October 14, 2023 Author Share Posted October 14, 2023 I have made the changes, doesn't seem to work yet. I am assuming I need to reload the scripts as I had to do for another change you helped me with. But I don't remember how to do that? Quote Link to comment Share on other sites More sharing options...
bsmither Posted October 14, 2023 Share Posted October 14, 2023 Have CubeCart clear its internal cache. Quote Link to comment Share on other sites More sharing options...
cqpbert Posted October 14, 2023 Author Share Posted October 14, 2023 perfect as always!! once again, bsmither for the win!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.