Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > how to validate a textBox for 0-9 Digits only

Reply
Thread Tools

how to validate a textBox for 0-9 Digits only

 
 
RSB
Guest
Posts: n/a
 
      06-10-2004
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


 
Reply With Quote
 
 
 
 
Raterus
Guest
Posts: n/a
 
      06-10-2004
Use a comparevalidator

Dim blah As CompareValidator

blah.Operator = ValidationCompareOperator.DataTypeCheck

blah.Type = ValidationDataType.Integer



"RSB" <(E-Mail Removed)> wrote in message news:yv%xc.3410$(E-Mail Removed)...
> 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
>
>

 
Reply With Quote
 
 
 
 
=?Utf-8?B?RWRtb25kIEdvb24=?=
Guest
Posts: n/a
 
      06-10-2004
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
>
>
>

 
Reply With Quote
 
=?Utf-8?B?RWRtb25kIEdvb24=?=
Guest
Posts: n/a
 
      06-10-2004
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
> >
> >
> >

 
Reply With Quote
 
Alan Ferrandiz Langley
Guest
Posts: n/a
 
      06-10-2004
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" <(E-Mail Removed)> escribió en el mensaje news:yv%xc.3410$(E-Mail Removed)...
> 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
>
>


 
Reply With Quote
 
chanmmn
Guest
Posts: n/a
 
      06-10-2004
Have you checked this:

http://msdn.microsoft.com/library/de...rolSamples.asp

chanmm

"RSB" <(E-Mail Removed)> wrote in message
news:yv%xc.3410$(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
RSB
Guest
Posts: n/a
 
      06-10-2004
Ok i tried this and it worked ValidationExpression="\d*"

"RSB" <(E-Mail Removed)> wrote in message
news:yv%xc.3410$(E-Mail Removed)...
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



 
Reply With Quote
 
Hannes Decorte
Guest
Posts: n/a
 
      06-14-2004
Check out

http://radio.weblogs.com/0132279/2004/06/13.html

Shorty
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
code challenge: generate minimal expressions using only digits 1,2,3 Trip Technician Python 12 02-27-2009 04:49 AM
matching only alphabetic chars and only digits with periods Jack Perl Misc 4 07-14-2006 10:22 PM
validate numeric range 6-10 digits Rob Wahmann Javascript 4 02-09-2004 04:28 PM
Validate only one textbox value Ray ASP .Net Web Controls 1 02-02-2004 09:46 AM
How to have One RequiredFieldValidator to Validate Two TextBox Nicolas ASP .Net 0 12-03-2003 02:43 PM



Advertisments