Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8938157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:33:48+00:00 2026-06-15T10:33:48+00:00

It seems that knockout validation plugin somehow prevents from executing click handlers. Here is

  • 0

It seems that knockout validation plugin somehow prevents from executing click handlers.
Here is my simplified code.

HTML:

<div>
    <input type="text" data-bind="value: code" />
    <button data-bind="click: execute">VALIDATE</button>
</div

Javascript:

<script type="text/javascript" language="javascript">
    $(document).ready(function () {
        var ViewModel = function () {
            var self = this;
            this.code = ko.observable();
            this.code.extend({ required: true });
            this.execute = function () {
                if (self.code.isValid()) {
                    alert("SUCCEED");
                }
                else {
                    self.code.valueHasMutated(); //just to show error message
                    alert("FAILED");
                }
            };
        };

        ko.applyBindings(new ViewModel());
    });
</script>

My scenario:

  1. Load page
  2. Click VALIDATE – error message appears and alert shows FAILED
  3. Enter any text into input and immediately click VALIDATE – error message disappears, but no alert shown.
  4. Click VALIDATE again – only now alert can be seen with SUCCEED text.

How can this be fixed so the VALIDATE button will work correctly from the first click?

Thanks,
Ihor

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T10:33:49+00:00Added an answer on June 15, 2026 at 10:33 am

    3) You never click the button 😀

    What happens is that when you lose focus from the field it validates the field and the text is removed making the button change position and your click misses the button

    http://jsfiddle.net/s2bbd/

    This one works like you suspect
    http://jsfiddle.net/s2bbd/1/

    Stackoverflow wont let me post this without code
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using KnoockoutJS and the validation plugin from here, https://github.com/ericmbarnard/Knockout-Validation . By default, validation
It seems that often I find that my code when moving either from one
Most of Knockout seems very intuitive. One thing that is strange to me though
It seems that runClasses() doesn't terminate the code being tested even after the test
It seems that css animations on firefox are pixelating the edges of elements: Here
In attempting to integrate Knockout.js with Select2 , I noticed that what seems to
Seems,that very basic question. Anyway can't get the meaning of next definition from Spring
I have the following working code that uses Knockout to determine what color to
I have the following Javascript and Html code that works fine in an MVC4
Here's my scenario. I'm using the knockout mapping plugin to create an observable viewmodel

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.