[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Added 2 digits year and adding slashes

Posted on 2007-11-14
5
Medium Priority
?
574 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
ID: 20281867
0
 

Author Comment

by:pranathi27
ID: 20282015
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 2000 total points
ID: 20282240
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
ID: 20283353
thanks alot Jester!!!!
0
 
LVL 25

Expert Comment

by:James Rodgers
ID: 20283384
glad i could help

thanks for the points
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
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…
Suggested Courses

825 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