Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

feat: Added field validation for Email on sign in and sign up #286

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

sohamdata
Copy link

🛠️ Fixes Issue

Closes #252
Fixes the closed PR #265

➕ Changes Introduced

Added field validation for email on both signin and signup pages.
The field box ring and text is highlighted in tailwind color pink-600. "Please provide a valid email address" is displayed under it.

📷 Screenshots

fieldVal

@vercel
Copy link

vercel bot commented Oct 10, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
defaang ✅ Ready (Inspect) Visit Preview Oct 11, 2022 at 1:44PM (UTC)

@ykdojo
Copy link
Collaborator

ykdojo commented Oct 10, 2022

Thank you.

It's better than before, but I feel like it's still a bit annoying when the error message show up after a single character:

image

Can we show this message on pressing tab or going to the next field instead?

Copy link
Collaborator

@ykdojo ykdojo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

@sohamdata
Copy link
Author

sohamdata commented Oct 10, 2022

yeah, that can be changed, i can just set x in email.length > x to the desired min length. (It is 0 right now.)

@ykdojo
Copy link
Collaborator

ykdojo commented Oct 10, 2022

@sohamdata can we show it at tab pressing or when switching to a new field instead?

@sohamdata
Copy link
Author

@ykdojo I'll try, thanks for the feedback!

@sohamdata
Copy link
Author

@ykdojo it's fixed now.

Copy link
Collaborator

@ykdojo ykdojo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. That's much better, but I think there are a few small issues.

First of all, even when there's no error message, there's a space for it, and that breaks the format a little.

image

Secondly, it thinks "yk@example" is a valid email address when it shoudln't.

@sohamdata
Copy link
Author

I'll see what I can do, was thinking the same thing as well...

@sohamdata
Copy link
Author

hi, I don't think coding for "when there's no error message, there's a space for it" would just make the code more complicated, which isn't needed. It's better if we just highlight the textbox and its text if it's invalid.

@ykdojo
Copy link
Collaborator

ykdojo commented Oct 20, 2022

I just don't think having the whitespace there makes the UI look better in any way - it just makes it slightly worse.

I think it's okay if the code becomes slightly complicated.

@Princeton21
Copy link

@sohamdata Kindly acknowledge if you have finished working on the whitespace bug.

@sohamdata
Copy link
Author

sohamdata commented Oct 29, 2022

Sorry for replying late. The problem is:
Instead of rendering classes conditionally, we can render the whole <p>error message</p> conditionally instead.
But I don't know how to do that and/or integrate it with tailwindcss.

@subhoghoshX
Copy link
Collaborator

Sorry for replying late. The problem is: Instead of rendering classes conditionally, we can render the whole <p>error message</p> conditionally instead. But I don't know how to do that and/or integrate it with tailwindcss.

Just do { email.length && showEmailError && <p className="...">...</p> or something like that, i.e. pull the condition out of the template string.

Or you can reduce the error font size and also the margin so that the space isn't much noticeable. Something like this:

form-error.mp4

@sohamdata
Copy link
Author

@subhoghoshX thanks, I tried it, however, but after exiting email field, the space is left over.
i added:

{email.length && showEmailError ? 
    (<p className=
    {`invisible mt-2 text-sm text-pink-600 ${email.length > 0 && showEmailError ? 'peer-invalid:visible' : null`}
    >
    Please provide a valid email address. </p>) : null}

behavior:
newFixno

@subhoghoshX
Copy link
Collaborator

@sohamdata In that case just revert back to the previous state, as it was. Replace the invisible class with hidden and replace the pr-invalid:visible class with peer-invalid:block. I should work. Let me know how it goes.

@sohamdata
Copy link
Author

sohamdata commented Oct 29, 2022

@subhoghoshX that worked! thanks a lot!
Can you please tell me why it was that way earlier?

@subhoghoshX
Copy link
Collaborator

@subhoghoshX that worked! thanks a lot! Can you please tell me why it was that way earlier?

invisible means the element stays there, it's just invisible, so you see a white space in its place. hidden class applies the display: none CSS rule, which removes the element from the document flow.

@sohamdata
Copy link
Author

invisible means the element stays there, it's just invisible, so you see a white space in its place. hidden class applies the display: none CSS rule, which removes the element from the document flow.

Got it. I actually tried putting display: none in class earlier, but that resulted in strange behavior.

@sohamdata
Copy link
Author

sohamdata commented Oct 31, 2022

@ykdojo the problem is fixed, kindly see the changes and let me know.

Copy link
Contributor

@adilwahla adilwahla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks okay

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Highlight email input if its wrong.
5 participants