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