Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: How do I convert to date format?


Message #1 by "Ricky Yuen" <ricky_yuen@h...> on Fri, 08 Dec 2000 18:00:00 -0000
You could use regular expressions and the replace function() like this:

function formatDate(element) {

	element.value 
element.value.replace(/(\d{2})(\d{2})(\d{4})/,"$1/$2/$3");

}

function unformatDate(element) {

	element.value = element.value.replace(/\//g,"");
	
}


> Hi everyone,
> 
> Greeting from Los Angeles. I just have a question in date format. If I type
> a date in the textbox like "12082000", how can I use javascript to convert
> to the correct date format like "12/08/2000" on OnBlur event?
> 
> Any idea?
> 
> Thank so much.
> 
> Regards,
> Ricky

  Return to Index