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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:10:32+00:00 2026-06-16T00:10:32+00:00

See it in action! HTML: <input type=’text’ value=2012-12-30 Morning> <input type=’text’ value=2012-12-30 Lunch> <input

  • 0

See it in action!

HTML:

<input type='text' value="2012-12-30 Morning">
<input type='text' value="2012-12-30 Lunch">
<input type='text' value="2012-12-30 Dinner">
<input type='text' value="2012-12-30 Either akgalkgalkgla">
<input type='text' value="2012-12-30">
<input type='text' value="Morning">
<button>Check</button>

Javascript/jQuery:

$("button").click(function() {
    $("input")
        .filter(function() {
            return this.value.match(/[0-9]{4}-[0-9]{2}-[0-9]{2}\s[A-Za-z]+/);
        })
        .css("border", '1px solid red');

})​

I tried using the anchors ^ and $ but it doesn’t match it anymore. In the above example, it should NOT match “2012-12-30 Either akgalkgalkgla”

Here’s the regex
[0-9]{4}-[0-9]{2}-[0-9]{2}\s[A-Za-z]+

2012-12-30 Morning
2012-12-30 Lunch
2012-12-30 Dinner
2012-12-30 Either akgalkgalkgla

Update:

So ^[0-9]{4}-[0-9]{2}-[0-9]{2}\s[A-Za-z]+$ does work. I was initially trying this on regexpal, and it didn’t seem to work…

  • 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-16T00:10:32+00:00Added an answer on June 16, 2026 at 12:10 am

    Adding the anchors seems to work perfectly for preventing partial matches. The contents of the first three inputs are matched, the last three are not:

    $("button").click(function() {
        $("input")
            .filter(function() {
                return this.value.match(/^[0-9]{4}-[0-9]{2}-[0-9]{2}\s[A-Za-z]+$/);
            })
            .css("border", '1px solid red');
    });
    

    Here it is in action: http://jsfiddle.net/ZZYMG/4/

    If you want to apply the border to all the elements that fail this test, simply invert the boolean you are returning in the filter callback:

    return !this.value.match(/^[0-9]{4}-[0-9]{2}-[0-9]{2}\s[A-Za-z]+$/);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider this HTML snippet: <input type='file' id='fileUpload' /> To get access to this control
Facebook recently introduced the Built-in Like as a built-in Open Graph action (see blogpost
EDIT: See this in action here: http://jsbin.com/emobi/5 -- and that's using mouseenter/mouseleave. I have
Despite warnings to drop my present course of action, I currently see no better
I am using cakePHP 1.26. I got an Input Text box which contains a
I've got the following code: <script type=text/javascript> $(function(){ $(#AddMaps).submit(function(){ var $form = $('#AddMaps'); $.ajax({
I've got the following HTML form. As you can see it's saving a file.
I've got a simple HTML form, thus: <html> <head></head> <body> <form action=upload_file.php method=post enctype=multipart/form-data>
im new to sessions but from what i see it complicated to apply <input>
please see these html codes : <!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>

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.