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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:00:33+00:00 2026-05-30T07:00:33+00:00

I have been looking for a decent jQuery validation methodology. I found this jsFiddle

  • 0

I have been looking for a decent jQuery validation methodology. I found this jsFiddle That does something similar

But I need mine to validate with AM\PM and also not be a required field for form submission. And If I could get this to work onBlur only then that would be great.

An example acceptable time would be

12:00 AM

While there is an infinite example of unacceptable strings, this is just one of them

24:00

Now that I think about it, I would want this thing not to submit if the format is not valid, but If there is no entered time, I don’t want the validator to fire.
Tried this with the jquery validator, but it is not working.

$().ready(function() {

$.validator.addMethod("time", function(value, element) {  
return this.optional(element) || /^(([0-1]?[0-2])|([2][0-3])):([0-5]?[0-9])(a|p)m?$/i.test(value);  
}, "Please enter a valid time.");

    $("#login").validate({
            rules: {
                    time: "required time",
            },

    });

});
  • 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-30T07:00:35+00:00Added an answer on May 30, 2026 at 7:00 am

    I’d point you to the indispensible jquery.validator: http://docs.jquery.com/Plugins/Validation. Yeah, you’ll need to take a little time to figure it out but it is time well spent. When it comes to something as universally used as validation, someone has already done the heavy lifting, no need to reinvent the wheel, if you’ll excuse my overuse of metaphors.

    Edit: I have had a change of opinion regarding validation. This may be somewhat tangential to the original question, but in general, I like the idea of masking/limiting fields to prevent 80-90% of user error, and the remainder can be validated via an ajax call to server-side FluentValidation. This strategy removes the need for jquery.validator and (most) other client-side validation. A workable and preferable approach in many situations. (Disclaimer: I am not affiliated with FluentValidation in any way other than as a user)

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

Sidebar

Related Questions

I have been looking around and found no solution for this issue. Let say
Have been looking at the MVC storefront and see that IQueryable is returned from
I have been looking at jQUery thickbox for showing modal dialogs with images, it
Sorry If something like this has already been asked, but I can't find exactly
Ok, so I feel like a complete idiot asking this, but I've been looking
Hey all. I've been looking for a while for something that can help me
I have been looking into design patterns in Javascript and found http://tcorral.github.com/Design-Patterns-in-Javascript/Template/withoutHook/index.html to be
I have been looking around the Twitter api without much luck. Does anyone know
I have been looking at this article about using tasks in C#, and I
I have been looking into IKVMing Apache's FOP project to use with our .NET

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.