Solved

Added 2 digits year and adding slashes

Posted on 2007-11-14
5
563 Views
Last Modified: 2012-06-21
hi
i need code which converts 2 digits years to 4 digit years and also add slashes to that date using java script.
0
Comment
Question by:pranathi27
  • 2
  • 2
5 Comments
 
LVL 17

Expert Comment

by:contactkarthi
Comment Utility
0
 

Author Comment

by:pranathi27
Comment Utility
this is the function i have which  adds slashes to 4 digit year.but i need to add  some code to this function so that it will convert 2 digit year to 4 digits and also slashes.
function abcd(dd)
{
if (dd.value != "")
        {
            var md = dd.value;
            if ((md.length == 8) && (md.indexOf("/") == -1)  && (md.indexOf("-") == -1))
            {
                           dd.value = md.substring(0,2) + "/" + md.substring(2,4) + "/" + md.substring(4,8);
}
            }

please help
0
 
LVL 25

Accepted Solution

by:
James Rodgers earned 500 total points
Comment Utility
try this
function abcd(dd){
      if (dd.value != ""){
            var md = dd.value;
            if ((md.length == 8 || md.length==6) && md.indexOf("/") == -1  && md.indexOf("-") == -1){
                  dd.value = md.substring(0,2) + "/" + md.substring(2,4) + "/" + (md.length == 8 ? md.substring(4,8) : "20" + md.substring(4,8));
            }
      }
}
0
 

Author Comment

by:pranathi27
Comment Utility
thanks alot Jester!!!!
0
 
LVL 25

Expert Comment

by:James Rodgers
Comment Utility
glad i could help

thanks for the points
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Form submit issue 11 51
date format angularjs2 16 36
Get Javascript URL parameters 7 27
addressing a specific html page 9 18
In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now