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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:54:16+00:00 2026-06-07T18:54:16+00:00

I have a code to validate the date in the form of MMYY format.This

  • 0

I have a code to validate the date in the form of MMYY format.This shows dynamic popup dialog box before submitting the button. For this the code is given below as:

<ext:text name="caseDetailForm" property="phaseData.phaseDateExpiration" styleId="_dateExp"
                    style="width:100px" maxlength="4" titleKey="prompt.exp.date" onkeyup="validateCardExpiry(this);" />

and the function is:

function validateCardExpiry(field) {
    var cardExpRegEx1or2char = /^(0[1-9]?|1[0-2]?)$/;
    var cardExpRegEx3or4char = /^(0[1-9]?|1[0-2])[0-9]?[0-9]?$/;
    var cardExpDate = field.value;
    var msg = '<bean:message key="errors.bad.input.characters.detected"/> - '+cardExpDate;
        + '\n' + "<bean:message key="prompt.exp.date"/>";
    var failed = false;
    for (var x = cardExpDate.length; x >= 0; x--) {
        cardExpDate = cardExpDate.substring(0, x);
        if (cardExpDate.length > 0 && 
            ((cardExpDate.length <= 2 && !cardExpRegEx1or2char.test(cardExpDate)) 
            || (cardExpDate.length > 2 && !cardExpRegEx3or4char.test(cardExpDate)))) {
            failed = true;
        }
        else {
            field.value = cardExpDate;
            break;
        }
    }
    if (failed) {
        alert(msg);
    }
}

for MMYY validation is working fine with above code. But i need MM/DD/YYYY validation. For this how can i validate with popup window in the same scenario.

  • 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-07T18:54:18+00:00Added an answer on June 7, 2026 at 6:54 pm

    You can do something like:

    function validateDate(s) {
      var bits = s.split('/');
      var d = new Date(bits[2], ++bits[0], bits[1]);
      return d.getFullYear == bits[2] && d.getDate == bits[1];
    }
    

    but the format mm/dd/yyyy is not used by that many people, most use either dd/mm/yyyy or yyyy-mm-dd.

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

Sidebar

Related Questions

I have the following code to validate two text box entries to make sure
I have the following code using jQuery Validate. $(#register).validate({ debug: true, errorClass:'error', validClass:'success', errorElement:'span',
I have a standard code like below to validate xml against xsd, but it
I have the following code to enable validation work: $(document).ready(function() { $(#eventForm).validate({ rules: {
In my code, I have two text boxes that validate input as the user
I have a model defined this way class Lga < ActiveRecord::Base validates_uniqueness_of :code validates_presence_of
I have code like this in my view model: function ChatListViewModel(chats) { var self
Please help me to refactore this Javascript code. There is big form for scheduled
I have a form containing a date and datetime field: @Html.TextBoxFor(model => model.A, new
I have a form with the following format: <form id=program name=program method=get action=process.jsp> <div

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.