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. CNIC Validation

CNIC Validation

Scheduled Pinned Locked Moved ASP.NET
csharp
2 Posts 2 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.
  • S Offline
    S Offline
    sparlay_pk
    wrote on last edited by
    #1

    I want to put validation control for CNIC (Computed National Identity Card), if CNIC# is: 16304-1064020-6 I want the dashes to be handled automatically. like if I first enter 16304 now if I enter another digit like in this case 1 then the dash between them is automatically putted.

    A 1 Reply Last reply
    0
    • S sparlay_pk

      I want to put validation control for CNIC (Computed National Identity Card), if CNIC# is: 16304-1064020-6 I want the dashes to be handled automatically. like if I first enter 16304 now if I enter another digit like in this case 1 then the dash between them is automatically putted.

      A Offline
      A Offline
      Abhishek Sur
      wrote on last edited by
      #2

      Then do it. Just handle the keypress of the textboxes you want, and use javascript to put dashes between numbers. You might also consider Regular Expression to validate the CNIC number after user input. (Might also make use of RegularExpressionValidator).

      \d{5}[-|]\d{7}[-|]\d

      I think this will work as regular expression. Try it. Well I agree, it can be made shorter. Cheers. :rose:

      Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


      My Latest Articles-->** Simplify Code Using NDepend
      Basics of Bing Search API using .NET
      Microsoft Bing MAP using Javascript

      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