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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:32:55+00:00 2026-06-13T11:32:55+00:00

Ok so this is a really simple scenario which I can’t figure out since

  • 0

Ok so this is a really simple scenario which I can’t figure out since I’ve just started with MVC. I have created a custom password validator to use both client and server side. For the meantime the client-side validator does nothing but check the length (it will do more than this once I get it working). The server-side validation works fine. This is the client side implementation

$.validator.unobtrusive.adapters.add("password",
    function (options) {
        options.rules['password'] = {};
        options.messages['password'] = options.message;
    }
);
$.validator.addMethod("password", function (value, element, params) {
    if (value.length < 8 || value.length > 15) {
        return false;
    }
    return true;
}); 

I only want this validator to fire when the form is submitted.

Currently, as soon as you start typing it tells you that your password is invalid until the password meets the length requirements. I want it to act like the standard ‘Required’ validators I have on other form fields where they only validate the input once the form is submitted.

  • 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-13T11:32:56+00:00Added an answer on June 13, 2026 at 11:32 am

    Right so I found a similar question with some answers on disabling the keyup feature here: ASP.net MVC 3 jQuery Validation; Disable Unobtrusive OnKeyUp? But I found another way to do it, which doesn’t involve writing extra lines of javascript or turning the functionality off on all fields. Basically, I just changed the actual function inside the jquery.validation.js file to check for an attribute called nokeyup and if it’s found then return. You can find the onkeyup function not too far from the start of the file. It originally looks like this

    onkeyup: function(a, b) {
        if ( b.which === 9 && this.elementValue(a) === '' ) {
            return;
        }
        else if ( a.name in this.submitted || a=== this.lastActive ) {
            this.element(a);
        }
    },
    

    So I changed it to

    onkeyup: function (a, b) {
        if (b.which === 9 && this.elementValue(a) === "") { 
            return;
        }
        else if (a.getAttribute('nokeyup')) { // Added this statement
            return;
        } 
        else if ( a.name in this.submitted || a=== this.lastActive ) {
            this.element(a);
        }
    },
    

    After that all that I had to do was add the ‘nokeyup’ attribute to my text boxes which I didn’t want to fire the validation for until form submission and voila.

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

Sidebar

Related Questions

hey guys having this really simple problem but cant seem to figure out have
I have this simple scenario: main.m (which is my main class) myClass.m (which is
I'm sure this is really simple, but I can't for the life of me
I'm sure this is really simple, but I can't seem to get it working.
What I want is pretty simple conceptually but I can't figure out how it
I've got this really simple piece of code that I thought was the correct
I'm going to run this really simple cod that will be compiled in visual
I'm sure this is really simple and I'm drawing a giant blank, but how
I know this probably really simple but Im not sure what im doing wrong...
I know this is really simple but I cant find the docs for this

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.