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. validation

validation

Scheduled Pinned Locked Moved ASP.NET
13 Posts 4 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.
  • A Offline
    A Offline
    A kamath
    wrote on last edited by
    #1

    I want to know how should we give validation for phone numbers. my phone number format is 0000-000-000

    R S S 3 Replies Last reply
    0
    • A A kamath

      I want to know how should we give validation for phone numbers. my phone number format is 0000-000-000

      R Offline
      R Offline
      RepliCrux
      wrote on last edited by
      #2

      Heared of Regular expression ?

      A 1 Reply Last reply
      0
      • A A kamath

        I want to know how should we give validation for phone numbers. my phone number format is 0000-000-000

        S Offline
        S Offline
        SHatchard
        wrote on last edited by
        #3

        There are a couple of easy ways 1. Client-side There is a nice ASP.net AJAX control in the toolkit which offers this if you want to use it. Link - http://ajax.asp.net/ajaxtoolkit/MaskedEdit/MaskedEdit.aspx[^] 2. Regular expression validator You could write a simple regular expression to match the input against and use a validator on the page. The regular expression would be something like ^d{4}-\d{3}-\d{3}$ (Not 100% sure of the exact syntax) Try www.regexlib.com as a great source for help and examples of regular expressions.

        A 1 Reply Last reply
        0
        • S SHatchard

          There are a couple of easy ways 1. Client-side There is a nice ASP.net AJAX control in the toolkit which offers this if you want to use it. Link - http://ajax.asp.net/ajaxtoolkit/MaskedEdit/MaskedEdit.aspx[^] 2. Regular expression validator You could write a simple regular expression to match the input against and use a validator on the page. The regular expression would be something like ^d{4}-\d{3}-\d{3}$ (Not 100% sure of the exact syntax) Try www.regexlib.com as a great source for help and examples of regular expressions.

          A Offline
          A Offline
          A kamath
          wrote on last edited by
          #4

          thanks

          1 Reply Last reply
          0
          • R RepliCrux

            Heared of Regular expression ?

            A Offline
            A Offline
            A kamath
            wrote on last edited by
            #5

            yes

            1 Reply Last reply
            0
            • A A kamath

              I want to know how should we give validation for phone numbers. my phone number format is 0000-000-000

              S Offline
              S Offline
              Sathesh Sakthivel
              wrote on last edited by
              #6

              Here is your code for Validation of Phone Number, with asp:regularexpressionvalidator <%@ Page Language=VB Debug=true %> Validating a Phone Number with a RegularExpressionValidator Control

              Please enter your phone number:
              You must enter a phone number in the form of 9999-999-999.

              Regards, Satips.:rose:

              A 1 Reply Last reply
              0
              • S Sathesh Sakthivel

                Here is your code for Validation of Phone Number, with asp:regularexpressionvalidator <%@ Page Language=VB Debug=true %> Validating a Phone Number with a RegularExpressionValidator Control

                Please enter your phone number:
                You must enter a phone number in the form of 9999-999-999.

                Regards, Satips.:rose:

                A Offline
                A Offline
                A kamath
                wrote on last edited by
                #7

                Thanks, but if the first number should be either 3 or 4 so how should we give? like 0000-000-000 or 000-000-000

                S 2 Replies Last reply
                0
                • A A kamath

                  Thanks, but if the first number should be either 3 or 4 so how should we give? like 0000-000-000 or 000-000-000

                  S Offline
                  S Offline
                  Sathesh Sakthivel
                  wrote on last edited by
                  #8

                  The first digit is only three. Like wise you have to mention. (999) 999-9999.

                  Regards, Satips.:rose:

                  1 Reply Last reply
                  0
                  • A A kamath

                    Thanks, but if the first number should be either 3 or 4 so how should we give? like 0000-000-000 or 000-000-000

                    S Offline
                    S Offline
                    Sathesh Sakthivel
                    wrote on last edited by
                    #9

                    But i have given the code as you have asked for four digit in the first as you stated. If you want you can change the code for three.

                    Regards, Satips.:rose:

                    A 1 Reply Last reply
                    0
                    • S Sathesh Sakthivel

                      But i have given the code as you have asked for four digit in the first as you stated. If you want you can change the code for three.

                      Regards, Satips.:rose:

                      A Offline
                      A Offline
                      A kamath
                      wrote on last edited by
                      #10

                      Thanks .Can we keep both either 3 or 4 in single expression.because some phone no is having 4 digit first and some having 3 digit first.

                      S 1 Reply Last reply
                      0
                      • A A kamath

                        Thanks .Can we keep both either 3 or 4 in single expression.because some phone no is having 4 digit first and some having 3 digit first.

                        S Offline
                        S Offline
                        Sathesh Sakthivel
                        wrote on last edited by
                        #11

                        A kamath wrote:

                        Can we keep both either 3 or 4 in single expression.because some phone no is having 4 digit first and some having 3 digit first.

                        Not Both at a time go with any one. Mostly the standard format is (999) 999-9999. like this only. The first three numbers inside braces denotes the Code and the other seven numbers will represents the other. Everywhere you see only 10 didgit phone number only.

                        Regards, Satips.:rose:

                        A 1 Reply Last reply
                        0
                        • S Sathesh Sakthivel

                          A kamath wrote:

                          Can we keep both either 3 or 4 in single expression.because some phone no is having 4 digit first and some having 3 digit first.

                          Not Both at a time go with any one. Mostly the standard format is (999) 999-9999. like this only. The first three numbers inside braces denotes the Code and the other seven numbers will represents the other. Everywhere you see only 10 didgit phone number only.

                          Regards, Satips.:rose:

                          A Offline
                          A Offline
                          A kamath
                          wrote on last edited by
                          #12

                          Thank you.

                          S 1 Reply Last reply
                          0
                          • A A kamath

                            Thank you.

                            S Offline
                            S Offline
                            Sathesh Sakthivel
                            wrote on last edited by
                            #13

                            Welcome :)

                            Regards, Satips.:rose:

                            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