how to validate a textBox for 0-9 Digits only

Discussion in 'ASP .Net' started by RSB, Jun 10, 2004.

  1. RSB

    RSB Guest

    Hi every one,
    how do i check the text box that one can only enter the numeric Digits. i
    have the maxlength of the Text box as 6. so one way i thought was to
    validate the Number between 0 and 999999. so is there any other way ..say
    using the RegularExpressionValidator control.

    Thanks
    RSB
     
    RSB, Jun 10, 2004
    #1
    1. Advertising

  2. RSB

    Raterus Guest

    Use a comparevalidator

    Dim blah As CompareValidator

    blah.Operator = ValidationCompareOperator.DataTypeCheck

    blah.Type = ValidationDataType.Integer



    "RSB" <> wrote in message news:yv%xc.3410$...
    > Hi every one,
    > how do i check the text box that one can only enter the numeric Digits. i
    > have the maxlength of the Text box as 6. so one way i thought was to
    > validate the Number between 0 and 999999. so is there any other way ...say
    > using the RegularExpressionValidator control.
    >
    > Thanks
    > RSB
    >
    >
     
    Raterus, Jun 10, 2004
    #2
    1. Advertising

  3. You could also have used something along the lines of

    <asp:RegularExpressionValidator id="Validator1" ASPClass="RegularExpressionValidator" ControlToValidate="YouTextField" ValidationExpression="[0-9]{6,}"runat="server"></asp:RequiredFieldValidator>
    --
    Edmond Goon

    "As far as the laws of mathematics refer to reality, they are not certain; and as far as they are certain, they do not refer to reality." - Einstein


    "RSB" wrote:

    > Hi every one,
    > how do i check the text box that one can only enter the numeric Digits. i
    > have the maxlength of the Text box as 6. so one way i thought was to
    > validate the Number between 0 and 999999. so is there any other way ..say
    > using the RegularExpressionValidator control.
    >
    > Thanks
    > RSB
    >
    >
    >
     
    =?Utf-8?B?RWRtb25kIEdvb24=?=, Jun 10, 2004
    #3
  4. Sorry, I typed in the wrong closing tag obviously...closing tag should be
    </asp:RegularExpressionValidator>
    --
    Edmond Goon

    "As far as the laws of mathematics refer to reality, they are not certain; and as far as they are certain, they do not refer to reality." - Einstein


    "Edmond Goon" wrote:

    > You could also have used something along the lines of
    >
    > <asp:RegularExpressionValidator id="Validator1" ASPClass="RegularExpressionValidator" ControlToValidate="YouTextField" ValidationExpression="[0-9]{6,}"runat="server"></asp:RequiredFieldValidator>
    > --
    > Edmond Goon
    >
    > "As far as the laws of mathematics refer to reality, they are not certain; and as far as they are certain, they do not refer to reality." - Einstein
    >
    >
    > "RSB" wrote:
    >
    > > Hi every one,
    > > how do i check the text box that one can only enter the numeric Digits. i
    > > have the maxlength of the Text box as 6. so one way i thought was to
    > > validate the Number between 0 and 999999. so is there any other way ..say
    > > using the RegularExpressionValidator control.
    > >
    > > Thanks
    > > RSB
    > >
    > >
    > >
     
    =?Utf-8?B?RWRtb25kIEdvb24=?=, Jun 10, 2004
    #4
  5. You could use a RegularExpressionValidator along with a RequiredFieldValidator to check for blank spaces, the validation expression could be something like:

    RegularExpressionValidator1.ValidationExpression = "^\d*[0-9]$"

    so that you accept only digits from 0 to 9

    Hope this helps

    Alan Ferrandiz L.
    MCT, MCDBA, MCSD
    MSF Practitioner






    "RSB" <> escribió en el mensaje news:yv%xc.3410$...
    > Hi every one,
    > how do i check the text box that one can only enter the numeric Digits. i
    > have the maxlength of the Text box as 6. so one way i thought was to
    > validate the Number between 0 and 999999. so is there any other way ...say
    > using the RegularExpressionValidator control.
    >
    > Thanks
    > RSB
    >
    >
     
    Alan Ferrandiz Langley, Jun 10, 2004
    #5
  6. RSB

    chanmmn Guest

    Have you checked this:

    http://msdn.microsoft.com/library/d...cpguide/html/cpconValidatorControlSamples.asp

    chanmm

    "RSB" <> wrote in message
    news:yv%xc.3410$...
    > Hi every one,
    > how do i check the text box that one can only enter the numeric Digits. i
    > have the maxlength of the Text box as 6. so one way i thought was to
    > validate the Number between 0 and 999999. so is there any other way ..say
    > using the RegularExpressionValidator control.
    >
    > Thanks
    > RSB
    >
    >
     
    chanmmn, Jun 10, 2004
    #6
  7. RSB

    RSB Guest

    Ok i tried this and it worked ValidationExpression="\d*"

    "RSB" <> wrote in message
    news:yv%xc.3410$...
    Hi every one,
    how do i check the text box that one can only enter the numeric Digits. i
    have the maxlength of the Text box as 6. so one way i thought was to
    validate the Number between 0 and 999999. so is there any other way ..say
    using the RegularExpressionValidator control.

    Thanks
    RSB
     
    RSB, Jun 10, 2004
    #7
  8. Hannes Decorte, Jun 14, 2004
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nicolas
    Replies:
    0
    Views:
    630
    Nicolas
    Dec 3, 2003
  2. Trip Technician
    Replies:
    12
    Views:
    495
    Dan Goodman
    Feb 27, 2009
  3. Ray

    Validate only one textbox value

    Ray, Jan 31, 2004, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    111
  4. Rob Wahmann

    validate numeric range 6-10 digits

    Rob Wahmann, Feb 9, 2004, in forum: Javascript
    Replies:
    4
    Views:
    137
    Evertjan.
    Feb 9, 2004
  5. Jack
    Replies:
    4
    Views:
    161
    Ben Morrow
    Jul 14, 2006
Loading...

Share This Page