Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DOJO - Dynamically formatting phone number

 
Meghana Reddy
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I've a form where user creates his profile.

When he enters the phone number as say 1234567890, I would like to dynamically format the phone number as (123)456-7890. We are using Struts DOJO framework. Is there a simple way to do this?

Thanks in advance.
Megh
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do not think they have it, I know they have validation for it.

It is not that hard to do with a simple replace regular expression to remove anything that is not a number and one to add the formatting.

Eric
 
Meghana Reddy
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Eric

I'm new to DOJO/AJAX world.

Do you know of any tutorial that can quickly get me up to speed ?

We have a bunch of such validations/formatting to do.

Can this be done using dojo.string.substitute?

Thanks
Megh
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have not used Dojo in a longt ime so I am not the best person to ask about it.

You might want to post over on the Dojo firums where they have people to really use it there: http://dojotoolkit.org/support

Eric
 
Arlo White
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This reformats a ValidationTextBox value as ###-###-####.

The default filter method comes from _TextBoxMixin.js, which is where trim, uppercase, lowercase, and propercase is implemented.


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic