tanhaa wrote:
> ASM wrote:
> > tanhaa a écrit :
> > > Hi all,
> > >
> > > Just curious if Javascript can do this for me:
> > >
> > > I have data stored in a particular format and when displaying that
> > > data, I want it to be shown in specific format.
> >
> > On what moment do you want this ?
> > - during loading ?
> > - after loading ?
> > - for one or several numbers ?
> >
Just to answer the questions
I wanted it done during loading.
for several numbers, but the numbers are stored as a variable, so I'm
passing that variable through the javascript function.
> > Phone number formatted during loading,
> > add where you want it :
> >
> > <script type="text/javascript">
> > document.write(toPhone('3335551212'));
> > </script>
> >
now, the script does exactly what I want it to do, thank you for that.
However, what if some guy saves the number as 333.555-1212. Is there
any way for Javascript to take out the non-numerical characters and
turn it into a string of 3335551212 and then apply the format of (333)
555-1212?
Not so important for me, I am just curious for my own knowledge.
I know php can do that by use ereg() function i believe.
TIA.
Regards,
Amit Malhotra