ASP.NET Web developers, are you tired dragging and dropping validator controls to the textbox that needs to have validation against user inputs on Web. It might be said time and effort-consuming to have validation checking in textboxes using ASP.NET 's shipped-in validator controls like RequiredFieldValidator and RegularExpressionValidator controls. IF you have 10 textboxes needs to be validated, you need to drag the validator controls at least 10 times (more than that if you use combination of both validators) from the toolbox.
I have developed a custom textbox server control, namely ValidTextBox that integrates validator controls (RegularExpressionValidator and RequiredFieldValidator) and normal textbox control during my weekend before Raya comes. It basically reduces the developers' validation checking effort in their development.
Figure 1 . You just need to drag one ValidTextBox server control instead of 3 server controls.
Basic Validation TypesThe ValidTextBox server control has 14 basic types of validation :
Figure 2 - Properties of ValidTextBox server control.
The ValidTextBox server control also exposes ErrorImageUrl property, which allows the developers to show an error image instead of text message when control is invalid.
When the ErrorImageUrl property is specified, the text in ErrorMessage property will be displayed as tooltip of the image shown. On the other hand, the ErrorMessage property will be shown if ErrorImageUrl property is empty (unspecified).
Flexibility of ValidTextBox Control1. Developers can freely define their own regular expression (CustomExpression property) for their own specific user input validation.2. Exposes common properties of validator control (eg. EnableClientScript, FontColor, ErrorMessage, CssClass), though not all of them.3. Each validation has default error message to be displayed. You can override the default one with your own custom error message.4. Similarly to the normal textbox server control, ValidTextBox server control inherits all of the properties of the <asp:TextBox server control.5. Properties can be either set programmatically, declaractively or at design-time.
<lvwc:ValidTextBox ID="ValidTextBox1"runat="server" AllowEmpty="False"> <RegExField ValidationType="Email" ErrorMessage="Invalid email address, brother!" CssClass="" CustomExpression=""></RegExField> <RequiredField ErrorMessage="**" CssClass=""></RequiredField></lvwc:ValidTextBox>
or
<lvwc:ValidTextBox ID="ValidTextBox1" RequiredField-ErrorMessage="**" RequiredField-CssClass="" RegExField-ValidationType="Email" RegExField-CssClass="" RegExField-CustomExpression="" runat="server" AllowEmpty="False"></lvwc:ValidTextBox>
DownloadsValidTextBox Server Control (dll) (Documentation will be uploaded once completed)(You also can download the ValidTextBox server control, specially for Malaysia context here)
Hope this control helps...