Skip to content

Conversation

@thiagotalma
Copy link

Usually the name of the field is not the best way of naming it.
It would be very nice to have the option to use the label to write the error message.

@thiagotalma
Copy link
Author

Another cool change would be this:

var matches = inputName.replace(/]$/, '').split(/]\[|[[\]]/g),
    inputShortName = matches[matches.length - 1];

if (window.Validation.shortNameMap[inputShortName]) {
    inputShortName = window.Validation.shortNameMap[inputShortName];
}

Anyway, the important thing is to give the possibility to define the names. 👍

@running-coder
Copy link
Owner

The reason I'm restricting the use of "label for" + "input name" use is purely for accessibility reasons. Imo the input field's name is the best way of targetting because this attribute is required to be POST / GET so might as well use it and avoid adding unnecessary attributes as much as possible.

Thanks for your feedback and suggestions!

@thiagotalma
Copy link
Author

@running-coder I understand your opinion.

But as I said, the field name is a "compromise" with the server. We need not concern ourselves with it, since the server knows what to expect. Some frameworks generate the field names, indecipherable.

On the other hand, we need to display a friendly error message to the user. There is also a issue language. The field name can be in English, but the user that accesses and receive the message reads only in Russian. Thought about it?

My suggestion in the second post is better than PR. It would be totally independent of the field, being able to map different languages​​.

@running-coder
Copy link
Owner

Ah! I see what you mean now, perhaps I misunderstood your previous explanation. I'll prepare something based on your suggestion to go around these constraints! thx

@thiagotalma
Copy link
Author

👍
I'm sure you'll find a better solution than my suggestion.

Will end with a limitation and allow your script to be used by people of other languages​​.

@running-coder
Copy link
Owner

Just released 1.3.3 which includes 3 ways of overriding the error message's inputName

Demo:
http://www.runningcoder.org/jqueryvalidation/demo/#form-contact_v1

Doc (you might need to hard refresh to get the location.hash scroll functionality):
http://www.runningcoder.org/jqueryvalidation/documentation/#validation-labels

enjoy!

@thiagotalma
Copy link
Author

As I said, I was sure that his solution would be very good! Congratulations! 👏 👏 👏

@muzzafarhasan
Copy link

input file validation??

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants