During development in .NET you came across a situation when we require min Minimum and maximum length checks on text boxes. Microsoft provided a very easy way to apply maximum length check. You just need to set MaxLength property. But to apply Min Length there is no such property. This check can be done using CustomValidator in the following way.
Write a javascript function which validates the input, Place TextBox and CustomValidator on page and set ClientValidationFunction property to the Function wriiten in javascript to validate input.
function validateLength ( src, args )
{
if (val.length >= 10)
{
args.IsValid = flag;
}
else
{
args.IsValid = false;
}
}
Write a javascript function which validates the input, Place TextBox and CustomValidator on page and set ClientValidationFunction property to the Function wriiten in javascript to validate input.
function validateLength ( src, args )
{
if (val.length >= 10)
{
args.IsValid = flag;
}
else
{
args.IsValid = false;
}
}
Comments