SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Zealot cruncher06's Avatar
    Join Date
    Feb 2009
    Location
    Illinois, USA
    Posts
    125
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question How to Create an InputMask for a PhoneNumber in an EditTemplate field in DetailsView

    I have a phone number in an EditTemplate field within a DetailsView control and would like to know how I can create an input mask so that the mask is (999) 999-9999

    Any ideas?

    Thanks.

    Chris S.

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,785
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Why would you want to use a phone number mask that doesn't fit most phone numbers? Phone numbers vary dramatically in how long each of the component parts of the number are depending on where in the world the phone number is.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  3. #3
    SitePoint Mentor NightStalker-DNS's Avatar
    Join Date
    Jul 2004
    Location
    Cape Town, South Africa
    Posts
    2,873
    Mentioned
    44 Post(s)
    Tagged
    0 Thread(s)
    You would have to use javascript. Try one of the jquery plugins for input masking. Usually works pretty well

  4. #4
    SitePoint Zealot cruncher06's Avatar
    Join Date
    Feb 2009
    Location
    Illinois, USA
    Posts
    125
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have tried using a jQuery plugin, but it does not appear to work for the editTemplate. Any thoughts what event I should place it in? I can upload the code if needed.

  5. #5
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,625
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Jquery plugin would be client-side, I don't think it would ever even be aware of the server-side event model. Anyhow, I haven't touched webforms in some time but my first thought would be to look at the ajax control toolkit, specifically the MaskedEdit bits.

    Personally I wouldn't waste much time on an input mask for phone numbers -- even if you are robodialing stuff most decent robodialers have some ability to parse phone numbers.

  6. #6
    SitePoint Zealot cruncher06's Avatar
    Join Date
    Feb 2009
    Location
    Illinois, USA
    Posts
    125
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks wwb_99. I was just trying to set up a format for internal use only where users would enter the number in themselves. I decided to use HTML5 to display how the phone number should be entered, but I'm not going to worry about validating it for now. I haven't been able to find a good AJAX example for phone numbers themselves and I'm trying to just use HTML5 and jQuery where I can and avoid the AJAX Control Toolkit. I successfully used jQuery on a web form text box server control, but just can't make it work in a Details Grid.
    Follow me on twitter: http://twitter.com/chrissergent

  7. #7
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,625
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    It is probably mainly an issue of finding the ID of the control. You can expose it via the ClientID property or you can cheat and use a css class to mark it and get the reference for jquery that way.


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •