Click here to Skip to main content
15,884,472 members
Articles / Web Development / HTML
Article

Hive Multi-Validating Self Textbox Control (Final Version)

Rate me:
Please Sign up or sign in to vote.
3.26/5 (17 votes)
2 Jul 20047 min read 81.5K   3.1K   46   6
Combines textbox, multi-validation and response labels in one control. Allows textbox to do self checking and self error response messages. Control can protect against SQL injection attacks and client script attacks with a special character set property.

Example

Introduction

This article demonstrates a control that combines textbox, multi-validation and response labels in one control. Allows textbox to do self checking and self error response messages. Control can protect against SQL injection attacks and client script attacks with a special character set property. You can also specify custom character sets for your control with the chars property. This control also includes many validation types to choose from: NONE, USERDEFINED, EMAIL, URL, ZIPCODE, PHONE, INTERNATIONALPHONE, DATE, ADVANCEDDATE, UKDATE, IPADDRESS, UKPOSTALCODE, SSN, CREDITCARD, PASSWORD, PERCENTAGE and GUID. Control can also run user defined validation types. Control also has built in range validation, bad word filter, required validator and comparison validator.

Language:

VB.NET and ASP.NET (For all you C# coders, who get paid more than VB.NET programmers!!! :P~)

Version:

1.0 - Final version.

How to use

Compile code into a .NET DLL assembly and put into your website home (bin) folder. Then add the following code to your ASP.NET webpage:

ASP.NET
<%@ Register TagPrefix="Hive" NameSpace="Hive.Controls" Assembly="Hive"%>

Then add the textbox control in your form:

ASP.NET
<Hive:textbox id="textbox1" runat="server" req="True"/>
Classes
Class NameDescription

Hive.Controls - Namespace

Description - Complex custom textbox user control.

HiveExceptionFor handling all Hive exceptions that can occur.
VB
Inherits ApplicationException
textboxHive multi-validating self textbox control.
VB
Inherits System.Web.UI.UserControl
Implements IValidator

 

Properties
Property NameTypeDescription
Control validation properties
IsValidBooleanChecks to see if this control is valid and returns it to the page validation.
ErrorMessageStringThe error message from the validator validation.
TypeValidationModeFor setting the type of validation to do. (Enumeration: ValidationMode) Types of validation - NONE | USERDEFINED | EMAIL | URL | ZIPCODE | PHONE | INTERNATIONALPHONE | DATE | ADVANCEDDATE | UKDATE | IPADDRESS | UKPOSTALCODE | SSN | CREDITCARD | PASSWORD | PERCENTAGE | GUID
CompareCompareModeFor setting the compare mode type of the textbox.
RangeTypeRangeModeFor setting the range type of the properties MinimumValue and MaximumValue.
MinimumValueStringFor setting the start parameter for range validation.
MaximumValueStringFor setting the end parameter for range validation.
CustomCharsErrorStringFor setting a custom CharsetMode regular expression error message.
CustomCharsStringFor setting a custom CharsetMode regular expression.
CustomRegExpStringFor setting the custom regular expression for the user-defined ValidationMode.
CustomErrorStringFor setting the custom error message for a user-defined ValidationMode.
CreditCardTypeStringA credit card type ReadOnly property of CardType enumeration.
BadWordsBooleanTo test textbox text for bad words and return an error.
CharsCharsetModeFor setting the type of characters allowed by the textbox. (Enumeration: CharsetMode) Types of characters - NONE | USERDEFINED | ALL | NONHTML | NOQUOTES | NODOUBLEQUOTES | ALPHA | ALPHANUMERIC | NUMERIC
ReqBooleanCheck to see if textbox is required field.
MaxIntegerFor setting the textbox max character length.
MinIntegerFor setting the textbox min character length.
Extended Textbox Control Properties
onSelectStringFor setting the textbox onSelect property.
onMouseUpStringFor setting the textbox onMouseUp property.
onMouseOverStringFor setting the textbox onMouseOver property.
onMouseOutStringFor setting the textbox onMouseOut property.
onMouseMoveStringFor setting the textbox onMouseMove property.
onMouseDownStringFor setting the textbox onMouseDown property.
onKeyUpStringFor setting the textbox onKeyUp property.
onKeyPressStringFor setting the textbox onKeyPress property.
onKeyDownStringFor setting the textbox onKeyDown property.
onFocusStringFor setting the textbox onFocus property.
onDblClickStringFor setting the textbox onDblClick property.
onClickStringFor setting the textbox onClick property.
onChangeStringFor setting the textbox onChange property.
onBlurStringFor setting the textbox onBlur property.
Control Style Properties
Style1StringFor setting the textbox CSS style.
Style2StringFor setting the error label CSS style.
Style3StringFor setting the display label CSS style.
Style4StringFor setting the CSS style of the required symbol asterisk.
TableBooleanBoolean property for creating tables around textbox and labels.
ReqSymbolBooleanAdds an asterisk to the end of the textbox.
LabelStringFor setting the label message of the textbox control.
Control Standard Properties
WidthIntegerFor setting the textbox width.
HeightIntegerFor setting the textbox height.
IDStringFor setting the textbox ID.
ID2StringFor setting the compare textbox ID.
ReadOnlyBooleanFor setting the textbox ReadOnly property.
TextStringFor setting the text value of the textbox control.
ValueStringThe value of the textbox control.
TextModeTextBoxModeFor setting the text mode of the textbox. (Enumeration: TextBoxMode) Types of modes - SINGLELINE | MULTILINE | PASSWORD.
ProperNameStringFor setting a proper name for the textbox control.
ProperName2StringFor setting the proper name of the compare control.

 

Enumerations
Enum constDescription

CharsetMode - Enumeration

Description - An enumeration of different types of allowed character sets.

NONEAllows no characters to be used.
USERDEFINEDAllows developer to specify characters to be used.
ALLAllows all characters to be used.
NONHTMLAllows all non HTML characters to be used.
NOQUOTESAllows all characters except quotes to be used.
NODOUBLEQUOTESAllows all characters except double quotes to be used.
ALPHAAllows all alpha characters to be used only.
ALPHANUMERICAllows all alpha-numeric characters to be used only.
NUMERICAllows all numeric characters to be used only.

ValidationMode - Enumeration

Description - An enumeration of different types of validations.

NONEAllows no validation type.
USERDEFINEDAllows developer to specify own validation regular expression type.
EMAILAllows email validation type.
URLAllows URL validation type.
ZIPCODEAllows zip code validation type.
PHONEAllows phone number validation type.
INTERNATIONALPHONEAllows international phone number validation type.
DATEAllows date validation type.
ADVANCEDDATEAllows advanced date validation type.
UKDATEAllows UK date validation type.
IPADDRESSAllows IP address validation type.
UKPOSTALCODEAllows UK postal code validation type.
SSNAllows social security number validation type.
CREDITCARDAllows credit card validation type.
PASSWORDAllows password validation type.
PERCENTAGEAllows percentage validation type.
GUIDAllows GUID validation type.

CompareMode - Enumeration

Description - An enumeration of different types of compare modes.

NONENo compare mode used.
EQUALCompare mode set to equal.
CASEEQUALCompare mode set to case equal.
NOTEQUALCompare mode set to not equal.

CardType - Enumeration

Description - An enumeration of different types of credit cards.

NONENo credit card type specified.
MASTERCARDMasterCard card type.
VISAVisa card type.
AMEXAmerican Express card type.
DISCOVERDiscover card type.
DINERSCLUBDiners Club card type.
ENROUTEEnRoute card type.
JCBJCB card type.

RangeMode - Enumeration

Description - An enumeration of types for setting range properties to that type.

NONESets the range mode to nothing.
CURRENCYSets the range mode type to currency.
DATESets the range mode type to Date.
DOUBLESets the range mode type to Double.
INTEGERSets the range mode type to Integer.
STRINGSets the range mode type to String.

Conclusion

Well, I am finally finished with my hive textbox control. It seemed like it was going to take an eternity to finish, well at least the document.

License:

Free to use and modify as long as header stays in place. Users must also send an email to the author's email address stating where they are using the code. If any modifications are made to this assembly, users must email changes to author's email address.

Terms and Conditions For Use, Copy, Distribution and Modification:

THIS CODE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS CODE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer (Senior) Codevendor
United States United States
Please visit my personal website https://codevendor.com for my latest codes and updates.

Comments and Discussions

 
GeneralDoubt Pin
smbrinda20-Nov-08 22:27
smbrinda20-Nov-08 22:27 
GeneralThank you for you contributions! Pin
Anonymous7-Aug-05 23:42
Anonymous7-Aug-05 23:42 
GeneralRe: Thank you for you contributions! Pin
noemailz15-Nov-06 3:34
noemailz15-Nov-06 3:34 
GeneralAuto Formatting Pin
vbfengshui5-Aug-05 4:30
vbfengshui5-Aug-05 4:30 
GeneralUPPERCASE &amp; Show Date now in textbox Pin
Nisarat30-May-05 2:15
Nisarat30-May-05 2:15 
GeneralUpdate Pin
M@dHatter5-Aug-04 14:01
M@dHatter5-Aug-04 14:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.