?
Solved

Added 2 digits year and adding slashes

Posted on 2007-11-14
5
Medium Priority
?
570 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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

764 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