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

  • Home
  • SEARCH
  • 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 7440035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:47:29+00:00 2026-05-29T10:47:29+00:00

I’m writing an MVC3 site, and I’m using JQuery unobtrusive validation to validate my

  • 0

I’m writing an MVC3 site, and I’m using JQuery unobtrusive validation to validate my forms. I’ve built a form framework within the app which shows a neat little “help” popup whenever I click on a form field. Everything works in that area, and I’m happy with it.

The issue is that I don’t have very much real estate available for the form field validation messages that are displayed besides each form, and if I put them underneath the form fields, the resizing is ugly. Here’s what a typical form field looks like:

Standard form field

When I click on the field, the following is shown:

Form field with help text shown

And when validation occurs, the following happens:

Form field with validation shown

My solution is to simply hide the help text when validation occurs (I use a shared function to do so, let’s call it “hideDescriptions()”). Every form in the site uses the same framework, so I want to be able to call hideDescriptions() whenever the unobtrusive validation occurs, at any point.

My javascript is split in to a number of files, for example:

/Review/Create/ – uses createReview.js
/Review/Read/ – uses readReview.js

They both also include “shared.js”. I was hoping to be able to extend the jquery unobtrusive validation plugin in the shared.js file, and apply it to every form in the site in one go… but I’m a bit lost. This is as far as I’ve gotten:

$("form").validate({
    invalidHandler: function (form, validator) {
        hideDescriptions();
    }
});

But I’m more than aware that won’t work. I assume that the unobtrusive validator attaches the validator to all forms by default, seeing as though I don’t need to attach it myself?

Is there a way I can extend the unobtrusive validation to perform a generic callback if the form is not valid?

  • 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-05-29T10:47:29+00:00Added an answer on May 29, 2026 at 10:47 am

    After spending 20 minutes writing that, I found this link, which pretty much solves my problem. Here’s the code I used:

    $("form").bind("invalid-form.validate", function () {
        hideDescriptions();
    });
    

    However, it’s almost useless as whenever the user clicks in the field again, the description is shown!

    Richard has also raised a valid point – I will re-evaluate the way my forms work 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am reading a book about Javascript and jQuery and using one of the
We're building an app, our first using Rails 3, and we're having to build
I am writing an app with both english and french support. The app requests
I am using Paperclip to handle profile photo uploads in my app. They upload
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.