[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
Solved

Posted on 2007-11-14
Medium Priority
572 Views
hi
i need code which converts 2 digits years to 4 digit years and also add slashes to that date using java script.
0
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
• 2
• 2

LVL 17

Expert Comment

ID: 20281867
0

Author Comment

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);
}
}

0

LVL 25

Accepted Solution

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

ID: 20283353
thanks alot Jester!!!!
0

LVL 25

Expert Comment

ID: 20283384

thanks for the points
0

## Featured Post

Question has a verified solution.

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

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
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
Course of the Month14 days, 2 hours left to enroll