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

The Archive Base Latest Questions

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

I use masked input on a input text field for a date in the

  • 0

I use masked input on a input text field for a date in the MM/YYYY format.
( http://digitalbush.com/projects/masked-input-plugin/ )

My javascript code:

jQuery(function($){
   $(".date").mask("12/2099");
});

And HTML Code:

<input type="text" class="date">

When I start to write something it take to the field the value 12/2099 and it’s impossible to write other thing.

If in javascript mask I write 99/9999, users could write date that is false … so I don’t what I have to do ?

I want to users that they could write starting on 01/1990 until 12/2099, possible adding to the restrict with the value of the date + 20 years or something like that …

  • 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-29T04:18:48+00:00Added an answer on May 29, 2026 at 4:18 am

    Well, I think is good to have the masked input but I prefer to validate the input value cause these kind of plugins generally works with regex from inside.

    My solution for this could be:

    (EDITED AND TESTED)

    Adding a div for a message

    <form id="frm">
        <input type="text" class="date">
        <div id="msg"></div>
        <input type="submit" value="Click Me"/>
    </form>
    

    the js:

         <script type="text/javascript">
    
                function verifyDate(datevalue) {
    
                  var done = false;
    
                  if(datevalue != null || datevalue != ''){
    
                    //split the date as a tmp var
                    var tmp = datevalue.split('/');
    
                    //get the month and year
                    var month = tmp[0];
                    var year = tmp[1];
    
                   if(month >= 1 && month <= 12){
                      if(year >= 1990 && year <= 2099){
    
                       //clean the message
                       clean();
    
                       //finally, allow the user to pass the submit
                       done = true;
    
                      } else {
                        $('#msg').html('Year must be from 1990 - 2099.');
                      }
                   } else {
                      $('#msg').html('Month is invalid.');
                   }
                }
                return done;
              }
    
              function clean() {
                 $('#msg').html('');
              }
    
              jQuery(function($) {
    
                 //mask the input
                 $(".date").mask("12/2099");
    
                 $('#frm').submit(function() {
                    var datevalue = $('.date').val();
                    return verifyDate(datevalue)           
                 });
    
                 $(".date").keyup(function(){
                    //get the date
                    var datevalue = $(this).val();
    
                    //only if the date is full like this: 'xx/xxxx' continue
                    if(datevalue.length == 7) {               
                      verifyDate(datevalue);
                    } else {
                      clean();
                    }
                 });
    
              });
    
        </script>
    

    Hope this helps.

    Regards.

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

Sidebar

Related Questions

I want to use jQuery Masked Input Plugin (http://digitalbush.com/projects/masked-input-plugin/) in my registration form. My
hos can create masked Input for date and time by jQuery? i not want
Here is a small example with the masked input plugin : //apply the mask
I'm using the jQuery Masked Input Plugin from here: Digital Bush I'm also using
The masked input plugin allows you to define constant-length masks. I am looking for
I am using jquery date input plugin from here I call the function inside
Use case: 3rd party application wants to programatically monitor a text file being generated
use LWP::Simple; use Parallel::ForkManager; @links=( [http://prdownloads.sourceforge.net/sweethome3d/SweetHome3D-2.1-windows.exe,SweetHome3D-2.1-windows.exe], [http://prdownloads.sourceforge.net/sweethome3d/SweetHome3D-2.1-macosx.dmg,SweetHome3D-2.1-macosx.dmg], [http://prdownloads.sourceforge.net/sweethome3d/SweetHome3DViewer-2.1.zip,SweetHome3DViewer-2.1.zip], ); # Max 30 processes for
Use case: I've just entered insert mode, and typed some text. Now I want
I have an input text element being used as a jQuery UI datepicker with

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.