varunKT001 / tomper-wear-ecommerce

E-commerce web-application for selling clothing essentials 😀
https://tomper-wear.netlify.app
MIT License
38 stars 48 forks source link

Fix Shipping Bug for Checking Zip Code #33

Closed Shubham29012001 closed 2 years ago

Shubham29012001 commented 2 years ago

Fix #30

Implement RegEx for Zip Code Validation in Shipping Page Form. Only Numeric 6 Digits will be allowed in Zip Code.

File Change

image

Note -

While I was working on Zipcode, I notice a bug that whenever a user changes phone number in shipping form, a warning error occurs about uncontrolled and controlled values for the phone number section. I am a little bit unaware of this error. I also followed the same steps at the official deployed site, but the error warning did not pop up over there.

Error -

image

netlify[bot] commented 2 years ago

‼️ Deploy request for tomper-wear rejected. Learn more about Netlify's sensitive variable policy

🔨 Explore the source changes: 18e91190acf3f73e2bb72dd928e2b635cf5650e1

varunKT001 commented 2 years ago

@Shubham29012001 Don't worry about that warning, it's because initially phone_number is null so react treats the input as uncontrolled, and when we change the value of phone_number the input becomes controlled. That's why React complaints. Ignore that warning 😅

Also, for the regex, move the if condition you implemented, next to the if where we are checking:

if (!postal_code) {
    ....
}
Shubham29012001 commented 2 years ago

Hey @varunKT001, can you please check now?

varunKT001 commented 2 years ago

@Shubham29012001 Done 👍 Thanks for contributing 🎉