Textbox with default value does not get detected in validation until a change is made

Viewed 13

So my register(post) part of my project is done. Now I am trying to do update profile (put). Btw, I didnt add the css designs or anything here just to make it simple. So, For the textboxes, for example for name I have:

<input defaultValue={name} />

So basically, one of my validations is

if(!Name) => {setError('blah blah')

and this works also when I call the info for profile update and put the defaultValue={name}, it also works.

so here is the problem: The textbox gets updated with the name that I call from the database however my validations do not work until i erase something.

Example: Someone registered as the name "John"

when I call John from database for profile update, my textbox gets updated with the name "John"

but if i dont erase a letter or add a letter, my validation wont work. It simply doesnt detect anything in the textbox. Even if i erase a letter from John and type it back, it will work. So to put it all together, I have do at least one thing in the textbox for my validation to detect it. I hope I haven't confused anyone. Let me know if additional info is needed.

0 Answers
Related