bootstrap-validator icon indicating copy to clipboard operation
bootstrap-validator copied to clipboard

Disabled submit with browser autocomplete fields

Open daniloef opened this issue 10 years ago • 15 comments

When I go to a browser autocomplete form and it's valid, the submit bottom is "disabled". When I clic the "body" or change the field focus it turn enabled, but is disabled in the "first view".

daniloef avatar Jun 27 '14 17:06 daniloef

Hmm, I'll look into it. Thanks.

1000hz avatar Jun 27 '14 17:06 1000hz

I too experience the same bug. I ended up using keyup() ,change() and also check if the input is empty or not, if has value run validation .

Tabishtabby avatar Jul 13 '14 17:07 Tabishtabby

Same problem here. Is there already a workaround or a solution?

devbas avatar Oct 24 '14 13:10 devbas

Browsers seem to be inconsistent with whether or not they raise input events whenever they autofill forms. If anyone has any ideas on how to get around this, please let me know.

1000hz avatar Nov 29 '14 07:11 1000hz

setTimeout(function() { $('#form').validator('validate'); }, 100);

msmyers avatar Jul 03 '15 22:07 msmyers

I can handle it with this workaround:

    <!--HTML-->
    ...
    <button type="submit" class="btn btn-primary" id="submit-btn">Submit</button>
    ...
    /* JavaScript */
    $(document).ready(function() {
        $("#submit-btn").click(function() {
            $('#form').validator('validate');
        });
    }

pradithahidayat avatar Oct 15 '15 09:10 pradithahidayat

Any solution for this yet? The best thing I've figured out it to just disable the 'disabled' class on buttons in validator.js -

//$btn.toggleClass('disabled', this.isIncomplete() || this.hasErrors())

builtwith avatar Jan 22 '16 02:01 builtwith

Thanks pradithahidayat it resolve my issue

shujakewl avatar Aug 15 '16 12:08 shujakewl

bro, you can focus and then blur your field in your ajax response, and is gonna validate ,i I had the same problem, but with this easy solution works perfectly :+1:

something like this:

success: function (data) {
            if (data.key == "1") {
                $("#EmpresaInt").empty().html(data.EmpInt); //Emp Interna
                $("#Empresa").empty().html(data.Cliente);
                $("#grupoemp").empty().html(data.Group);
//after load your fields with your response you gonna focus and then blur.

                $("#EmpresaInt").focus();
                $("#EmpresaInt").blur();

                $("#Empresa").focus();
                $("#Empresa").blur();

                $("#grupoemp").focus();
                $("#grupoemp").blur();
            }
        }

No matter the response of your ajax, the validator will load to give you the response.

irving-caamal avatar Jan 05 '17 16:01 irving-caamal

Having spent a couple of hours trying all of these solutions, I can confirm that nothing really works.

The problem is that these solutions work great when the page is loaded the first time, but on reload (ie. hit the refresh button) the password field will be auto-completed by Chrome but appear to be empty using any kind of Javascript logic. Hence bootstrap-validator will display that the field is empty, when it clearly isn't. You can read more here. Here is the bug in Chrome.. It seems there's some kind of security issue here, which is why it's not being fixed.

So my workaround is to disable the styling of a disabled button:

.btn.disabled {
  cursor: auto;
  opacity: 1;
}

Now it looks like they can login, even though javascript reports the password isn't there and the button technically has the disabled classs applied to it. When they click on the login button, Chrome will magically fire all the events it should have done on page load and then the disable class won't be applied inside of your click handler.

Ryan

rsshilli avatar Sep 05 '17 21:09 rsshilli

I personally fix it with <button type="submit" onMouseOver="$('#form').validator('validate')" ...>

FrancisYergeau avatar Nov 08 '17 20:11 FrancisYergeau

@FrancisYergeau I'm fascinated. I couldn't get this to work because the password says it's not validated. How did you get the password to be "set" in the password field?

rsshilli avatar Nov 13 '17 18:11 rsshilli

1st I don't use Chrome I prefer Opera (You said it yourself it's a bug in Chrome nothing you can do here, other than fixing Chrome ;) ) 2nd I use LastPass not the browser feature, more secure and work better.

Cheers, my solution work fine to disable or enable the submit btn when you need it just before click.

PS May be improve cause there is no onMouseOver on a mobile device... I'll come back with something...

FrancisYergeau avatar Nov 14 '17 13:11 FrancisYergeau

Has there been any progress on this issue (for Chrome)?

Bump.

bewards avatar Apr 02 '18 15:04 bewards

@bewards It seems that this repository is not maintained anymore. The last commit was Mar 16, 2017...

dunhamjared avatar Apr 02 '18 16:04 dunhamjared