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 8818269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:04:08+00:00 2026-06-14T05:04:08+00:00

I am using knockout.js and knockout.validation plugin. I have a search form which contains

  • 0

I am using knockout.js and knockout.validation plugin. I have a search form which contains 3 input fields for Name, Date and Country. I want to make sure that user must have fill at least 1 field before continuing search. For this reason i applied native validation rule required on all 3 fields. Here’s my code :

function SearchModel() {
    var self = this;

    self.Name = ko.observable().extend({ required: true });
    self.Date = ko.observable().extend({ required: true });
    self.Country = ko.observable().extend({ required: true });
    self.Errors = ko.validation.group(self);
}

I created a Errors property also which contains all validation messages if validation fails. Now when user submit the search form and if validation fails i don’t want to show all the error message below input fields instead i want to show a single message on the top of the form something like “You must have enter at least one filter for search”.

So my question is how can i hide all the messages and display a single message at the top of the form? Or if there is any other better way to do the same which i am trying to do than please let me know?

  • 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-14T05:04:09+00:00Added an answer on June 14, 2026 at 5:04 am

    Instead of setting each field to required, use a conditional to determine if one attribute has been provided.

    function SearchModel() {
        var self = this;
    
        self.Name = ko.observable();
        self.Date = ko.observable();
        self.Country = ko.observable();
        self.Errors = ko.validation.group(self);
        self.needsMore = ko.computed(function () {
          return !(self.Name() || 
            self.Date() ||
            self.Country);
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using knockout.js plugin. I have created a custom validation rule named select
I have a search form & knockout-based grid for results. When search is performed,
I have a fiddle in which i am using knockout.js. I created a custom
Because I am using Knockout in my view, I have set my form tag
We're using Knockout.js and the Knockout-validation plugin. When a user returns to a page
I am using Knockout Validation and have everything working as I wanted. I am
How can I do the following validation using knockout js? I have the following
I have a form which is rendered using html.RenderAction in MVC3. Outside of this
Html form is controlled using Knockout JS and jQuery templates. Basic jQuery validation is
I'm using KnoockoutJS and the validation plugin from here, https://github.com/ericmbarnard/Knockout-Validation . By default, validation

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.