Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How do I validate the value of a textbox from 0000 thru 9999 on the server side via VB.NET?

Posted on 2008-11-04
3
Medium Priority
?
287 Views
Last Modified: 2010-08-05
I need to validate if a textbox's value is between 0000 thru 9999 (with padded zeroes).  I have to implement it on the server side using VB.NET code.

How can I do this?
0
Comment
Question by:crickpaolo
3 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 2000 total points
ID: 22877597
Hello crickpaolo,

A regular expression of \d{4} will validate that easily, you can implement this as a regular expression validator client-side and then again server-side.

Regards,

TimCottee
  Imports System.Text.RegularExpressions 
Public Dim regex As Regex = New Regex( _
      "\d{4}", _
    RegexOptions.IgnoreCase _
    Or RegexOptions.CultureInvariant _
    Or RegexOptions.IgnorePatternWhitespace _
    Or RegexOptions.Compiled _
    ) 
Dim IsMatch As Boolean = regex.IsMatch(InputText)

Open in new window

0
 

Author Closing Comment

by:crickpaolo
ID: 31513141
thanks man.
0
 
LVL 26

Expert Comment

by:Anurag Thakur
ID: 22877728
make sure that your text box takes maximum input of 4 characters that also only numbers and no special characters alphabets and space or a dot
i will suggest you to do the first level of test by using a regularexpression validator then only verify again at the server side - why do you want to do a round trip for this kind of verification which can be easily done on the client side by regularexpression validator and the expression will be whats defined by TimCottee in the previous comment
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses
Course of the Month15 days, 19 hours left to enroll

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question