Use the maxlength like the above post or you can use javascript and a customvalidator control to check the length.
Use a custom validator with ValidateTextLength as its clientvalidatefunction name
function ValidateTextLength(source, args)
{
var length = $get('<%=txtYourTextBox.ClientID %>').value.length;
//this would make it valid unless the length is greater than 10
if (length <= 10)
args.IsValid = true;
else
args.IsValid = false;
}
Ask Me About: Kentico, XHTML, CSS, Javascript, Asp.Net C#, SQL Server.
jiveabillion
Contributor
4222 Points
775 Posts
Re: how can I check the number of characters entered into textbox prior to DB update?
Nov 08, 2010 06:40 PM|LINK
Use the maxlength like the above post or you can use javascript and a customvalidator control to check the length.
Use a custom validator with ValidateTextLength as its clientvalidatefunction name
function ValidateTextLength(source, args) { var length = $get('<%=txtYourTextBox.ClientID %>').value.length; //this would make it valid unless the length is greater than 10 if (length <= 10) args.IsValid = true; else args.IsValid = false; }Learn the LifeCycle
Free Online Games