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
Solved

Added 2 digits year and adding slashes

Posted on 2007-11-14
5
566 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 500 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
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…

856 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