Giter Club home page Giter Club logo

Comments (7)

oliversalzburg avatar oliversalzburg commented on August 20, 2024

Okay, part of this resolved itself. I forgot to add novalidate on the form and was seeing the Chrome validation bubble.

This was especially confusing because the example page exhibits the same problem

from jqbootstrapvalidation.

ReactiveRaven avatar ReactiveRaven commented on August 20, 2024

Hi Oliver!

While hunting for the source of this, I noticed something weird at https://github.com/ReactiveRaven/jqBootstrapValidation/blob/1.3.6/jqBootstrapValidation.js#L288 It looked to me like hasOverrideMessage is always true because the messages were set earlier. A simple alert(hasOverrideMessage) confirms this.

If you do $("body").data("something-that-isnt-there") you should get back undefined, because that data-attribute isn't defined. In dev-master I've simplified this to var hasOverrideMessage = !!message; to avoid confusion.

The value is read just fine using $this.data("validationRequiredMessage"), yet, the value isn't used. I confirmed this at https://github.com/ReactiveRaven/jqBootstrapValidation/blob/1.3.6/jqBootstrapValidation.js#L164

The pertinent bit there:

message = settings.builtInValidators.required.message;
if ($this.data("validationRequiredMessage")) {
  message = $this.data("validationRequiredMessage");
}

overwrites the default with your message from the data-attribute, so if you can read it in jQuery, it should be using your message fine.

Okay, part of this resolved itself. I forgot to add novalidate on the form and was seeing the Chrome validation bubble.

This was especially confusing because the example page exhibits the same problem

I agree. I'm in the process of rewriting the docs, but its taking me far too long. I've been neglecting the current version of the docs. Sorry about that.

Could you highlight the part that hasn't resolved itsself? Are you seeing your validation message now?

Thanks

  • RRaven

from jqbootstrapvalidation.

oliversalzburg avatar oliversalzburg commented on August 20, 2024

Hello @ReactiveRaven :)

As far as I can tell, my immediate problems were resolved. Adding the novalidate to my forms made everything behave as expected.

What wasn't resolved was the incorrect example on the documentation page, but you already touched on that subject.

I'm still confused regarding this section of the code though. As you've pointed out, you adjusted that code in master. However, to my understanding, my observations should still be true. If settings.options.sniffHtml is enabled, the message data members are explicitly set on all form elements: https://github.com/ReactiveRaven/jqBootstrapValidation/blob/master/dist/jqBootstrapValidation-1.3.6.js#L96.

For example, when putting required on an input, the data member will always be set. Thus, the hasOverrideMessage variable should always be true later on (even though the message wasn't actually overriden).

from jqbootstrapvalidation.

ReactiveRaven avatar ReactiveRaven commented on August 20, 2024

Ah, I understand now.

Yes, its not ideal. The easiest way of forcing a validator to be used is make sure a message is set for it, so thats what it does when it finds the 'required' attribute. I ran into this problem in master when adding tests and just went the easy way of making custom/default messages work for sniffed attributes. It still works, because the default message is being put in as the data-attribute that is overriding the.. default message. Convoluted, but you get the right result.

Its something I want to tidy up for 2.0 but it passes tests in master right now. I'll be coming back to this once I've got back in control of the issues list. Thanks for highlighting it :)

from jqbootstrapvalidation.

GuiDeto avatar GuiDeto commented on August 20, 2024

from jqbootstrapvalidation.

FFDomm avatar FFDomm commented on August 20, 2024

Hello.

I have 2 textboxes one user and password.

sig

and even if the first one is ok, it keeps saying "enter signum" when it should be asking for password.

This is the code for the textboxes:
code

Thanks in advace

from jqbootstrapvalidation.

FFDomm avatar FFDomm commented on August 20, 2024

I finally got it!

all i did was clear the custom validity property on each textbox

placeholder="Signum" required oninput="setCustomValidity('')" oninvalid="this.setCustomValidity('Please enter Signum')"

:)

from jqbootstrapvalidation.

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.