Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Limiting type and length in a textbox

Limiting type and length in a textbox

Scheduled Pinned Locked Moved ASP.NET
csharp
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Baatezu
    wrote on last edited by
    #1

    I have a web page where I need the user to enter a phone number and I have it divided into 3 boxes (I'm in the US) first 2 need 3 numbers and the last 4 digit It currently will accept anything and at any length, obviously not good for a phone number. Is there anyway to using ASP and VB.NET to limit the characters a text box will accept to numeric (without limiting the entire page) and limit how many characters the textbox will accept (again, not the entire page). I've tried putting code in the 'TextChanged' declaraction, but it never seemed to run. Any suggestions would be great. I don't trust the users to always enter the right info in the right places. The wisest of the wise may err. - Aeschylus Codito Ergo Sum

    C V 2 Replies Last reply
    0
    • B Baatezu

      I have a web page where I need the user to enter a phone number and I have it divided into 3 boxes (I'm in the US) first 2 need 3 numbers and the last 4 digit It currently will accept anything and at any length, obviously not good for a phone number. Is there anyway to using ASP and VB.NET to limit the characters a text box will accept to numeric (without limiting the entire page) and limit how many characters the textbox will accept (again, not the entire page). I've tried putting code in the 'TextChanged' declaraction, but it never seemed to run. Any suggestions would be great. I don't trust the users to always enter the right info in the right places. The wisest of the wise may err. - Aeschylus Codito Ergo Sum

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      You can add normal HTML tags to a textbox, and htey will go through to the client. You can set a maximum length property this way, but I'm not sure about numbers, I think you need to use javascript to do this. The obvious solution is to add validators that run on the client side, but I agree that it's nicer to not let the user enter the wrong thing to start with. Christian Graus - Microsoft MVP - C++

      1 Reply Last reply
      0
      • B Baatezu

        I have a web page where I need the user to enter a phone number and I have it divided into 3 boxes (I'm in the US) first 2 need 3 numbers and the last 4 digit It currently will accept anything and at any length, obviously not good for a phone number. Is there anyway to using ASP and VB.NET to limit the characters a text box will accept to numeric (without limiting the entire page) and limit how many characters the textbox will accept (again, not the entire page). I've tried putting code in the 'TextChanged' declaraction, but it never seemed to run. Any suggestions would be great. I don't trust the users to always enter the right info in the right places. The wisest of the wise may err. - Aeschylus Codito Ergo Sum

        V Offline
        V Offline
        Vasudevan Deepak Kumar
        wrote on last edited by
        #3

        Hi: Check out http://www.peterbailey.net/ for the fValidate JavaScript. It uses Rich RegEX for Phone validations. Deepak Kumar Vasudevan Personal Web: http://vdeepakkumar.netfirms.com/ I Blog At: http://deepak.blogdrive.com/

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups