Using a RequiredFieldValidator

When you need to ensure that a field is filled out by people who visit your website, you do not need a lot of complex code in a variety of scripting languages. ASP.NET VB corresponds to the task !

Create the table

Let’s create a sample form on which we can play, which is something that is used in real life. Create a table with four rows and two columns. Combine the cells of the first and last rows .

first thing to do, add the verbiage so we know what we are looking for. Row 1: “home page” Row 2 Column 1: “Username:” Row 3 Column 1: “Password: ”

Table Full

From the toolbox, add follows: Column 2 Row 2: HTML input box textRow type = 3 Column 3: entry box type HTML passwordRow = 4: Button

There are a couple of properties to be specified in the input boxes . To include “ID” and “runat”. In the input box to add user name: id = “txtUserName” runat = “server”. In the Password box enter: id = “txtPassword” runat = “server “.

Rename the button” Login “and add an event OnClick events through the window, while the Design view. It can be left empty .

While the sources of light, place your cursor immediately after the closing tag input box. Add a RequiredFieldValidator to the toolbox. An opening and closing tag will be created for you, along with default information. In-between the new tags, insert an asterisk to the server as a reminder that the missing information. To emphasize the Rose, add the following tag to open :

validator ForeColor = “red ”

As the validator controls nothing. To make it responsive to the input box for user name, add the following to open the tag validator :

ControlToValidate = “txtUserName ”

Design View

Repeat two step txtPassword entry box. Insert the validator, add the asterisk, ForeColor to change the color red, and finally add the ControlToValidate. Be sure to change the use “txtPassword” instead of “txtUserName. If you forget both validators looks the same input box Run the VB .

web application to test. Try to leave the username blank. Once you click the button, it triggers the validator and the red star is visible. The validator does not allow the form to be submitted until the field has contents. When the requirement is fulfilled, the red asterisk go away.

Featured Links:

Google Payload
Proven Money Maker At $9,547 A Day.
Burn The Fat Feed The Muscle
Burn The Fat - Top Selling Fat Loss Ebook Since 2003.
Save My Marriage Today!
Have You Ever Stayed Awake at Night Stressing About Whether or Not Your Marriage Will Last ... And What You Can Possibly Do to Save It?
Ultra Hot* SpywareBot: #1 AntiSpyware
Scan your computer for hidden AdWare and Spyware, Remove them permanently.
Top Movie Downloads
Join the Internet revolution and start downloading free movies and more!
Get Google Pay-Per-Click Ads Free!
Internet Marketer Gets $87 Million in Google Pay-Per-Click Ads FREE! ... And Makes Over $314 Million as a Result! ...And Now He's Going to Give You This Same Secret for Next to Nothing!
Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • bodytext
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • StumbleUpon
  • TwitThis

Leave a comment

You must be logged in to post a comment.