Skip to content
This repository has been archived by the owner on Mar 12, 2020. It is now read-only.

Separate native validator custom error messages #241

Closed
romain-granai opened this issue Nov 23, 2015 · 2 comments
Closed

Separate native validator custom error messages #241

romain-granai opened this issue Nov 23, 2015 · 2 comments

Comments

@romain-granai
Copy link

Hi,

I'm currently trying to validate 2 email forms.
The first on is a basic email and the second must match the first.
What I would like to do is :

  • When the email fields are empty, the error message should be "please enter your email address".
  • When the email fields are invalid (not an proper email address), the error message should be "Please enter a valid email".

the problem is that only data-error="something" is available. Is there a way to customize the error message when the field is empty AND a custom message when the field is invalid?

Furthermore, a valid email address should have a "@" AND a "." character to be valid, but actually the plugin make the field valid only if the "@" is present.

Thank you

@1000hz
Copy link
Owner

1000hz commented Nov 23, 2015

You can use data-native and data-match together for the second field, but for the first one, the best you can do at the moment is data-native="Please enter your email address" for both the empty state and the invalid state. This will be fixed when I have time to implement #212 for all validation types.

As for the email validation issue, that's not a bug. The . isn't required according to the spec. See #31 #178 #190.

@1000hz 1000hz changed the title Using proper validation message issue. Separate native validator custom error messages Nov 23, 2015
@jonw100
Copy link

jonw100 commented Dec 22, 2015

I must admit I too thought that the email validation was broken when it claimed validity as soon as the @ was present, and reading the spec I thought it did sound like there should be minimum of 2 groups of words separated by a dot. But then looking at the wikipedia entry
https://en.wikipedia.org/wiki/Email_address#Domain_part
that does contain a few examples of instances where the dot may not be part of an email address, so technically it may well be correct.

But, it would be a nice feature if the email validation could be enhanced to allow for developers to have the additional option of insisting on the presence of a dot also for validation success.

@1000hz 1000hz closed this as completed in b1afa2f Jul 15, 2016
andrews05 pushed a commit to andrews05/bootstrap-validator that referenced this issue Mar 16, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants