Coder Social home page Coder Social logo

TextValidators not displayed in error state on submit of form when there are validation issues about react-form-validator-core HOT 6 CLOSED

newoldmax avatar newoldmax commented on September 26, 2024
TextValidators not displayed in error state on submit of form when there are validation issues

from react-form-validator-core.

Comments (6)

NewOldMax avatar NewOldMax commented on September 26, 2024

Hi,

sorry, don't have too much time right now for answer, but in ideal world html form must not have inputs with the same name, because values will be overwritten for inputs with same names. So I followed this convention

from react-form-validator-core.

mike-strauch avatar mike-strauch commented on September 26, 2024

Hello!

sorry, don't have too much time right now for answer,

No worries, I appreciate the response.

but in ideal world html form must not have inputs with the same name, because values will be overwritten for inputs with same names

I'm not sure this is entirely true since you can and usually do have radio and/or checkbox inputs that have the same name. I think since inputs can have an id to make them unique having unique names is not really required. It's mostly up to the server to make sense of post data that has the same key (in this case the input name).

from react-form-validator-core.

NewOldMax avatar NewOldMax commented on September 26, 2024

If you will have text inputs with same name, server can't handle values correctly.

unique_name = value

So in case of radio inputs it's ok, because you're sending one value of them:

<radio name="abc" value="a" />
<radio name="abc" value="b" />

"abc" param can be "a" or "b" and that's fine.

But in case of text inputs it's not valid:

<textinput name="email" value="[email protected]" />
<textinput name="email" value="[email protected]" />

What value will be sent to backend? "[email protected]" or "[email protected]"? But you need both of them.
You can avoid this case with name="email[]", backend will get an array. Also you can handle this with current library by adding indexes (so names will be unique):

<textinput name="email[0]" value="[email protected]" />
<textinput name="email[1]" value="[email protected]" />

Anyway I plan to remove that 'unique name' requirement in future

from react-form-validator-core.

mike-strauch avatar mike-strauch commented on September 26, 2024

What value will be sent to backend? "[email protected]" or "[email protected]"? But you need both of them.

The browser will send both. In the case of using the get method on the form, the browser would just append the values onto the url like ?email=a&email=b. A post would basically basically do the same thing just not in the url.

You can avoid this case with name="email[]", backend will get an array.

That's really up to the backend you're using, though. As far as I've seen, there's nothing in the actual html spec that says you can't or shouldn't do it.

Anyway I plan to remove that 'unique name' requirement in future

That'd be great! If I get some time, I can submit a pull request for what I think would need changing if that would help things along.

Thanks!

from react-form-validator-core.

NewOldMax avatar NewOldMax commented on September 26, 2024

Please check the 0.6.1 version

from react-form-validator-core.

mike-strauch avatar mike-strauch commented on September 26, 2024

Awesome, thanks!

from react-form-validator-core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.