473,804 Members | 3,475 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Best way to check minimum length for a textbox field

Hello All,

Can I validate the minimum length of a field using any of the existing
validators?

I searched google on this subject and found people offering custom
controls for this.

However, for such a little thing it will be an overkill to bring in a
3rd party custom control. It will be great if I could use any of the
existing controls to check for minimum length.

Thanks for your help.

regards,
Abhishek.
Nov 18 '05 #1
2 11052
Dan
How about this - it checks for 5+ alphanumeric chars:

<asp:TextBox id="txtUsername " runat="server" />

<asp:RegularExp ressionValidato r
id="RegularExpr essionValidator 1"
runat="server"
ErrorMessage="F ield not valid!"
ControlToValida te="txtUsername "
ValidationExpre ssion="[0-9a-zA-Z]{5,}" />

"Abhishek Srivastava" <ab************ *****@nospam.ne t> wrote in message
news:uB******** ******@tk2msftn gp13.phx.gbl...
Hello All,

Can I validate the minimum length of a field using any of the existing
validators?

I searched google on this subject and found people offering custom
controls for this.

However, for such a little thing it will be an overkill to bring in a
3rd party custom control. It will be great if I could use any of the
existing controls to check for minimum length.

Thanks for your help.

regards,
Abhishek.

Nov 18 '05 #2
Custom Validator

private void yourValidator_S erverValidate(o bject source,
System.Web.UI.W ebControls.Serv erValidateEvent Args args)
{
if(this.yourTex tBox.Text.Lengt h == 0)
{
args.IsValid = false;
}

--
Curt Christianson
Owner/Lead Developer, DF-Software
www.Darkfalz.com
"Abhishek Srivastava" <ab************ *****@nospam.ne t> wrote in message
news:uB******** ******@tk2msftn gp13.phx.gbl...
Hello All,

Can I validate the minimum length of a field using any of the existing
validators?

I searched google on this subject and found people offering custom
controls for this.

However, for such a little thing it will be an overkill to bring in a
3rd party custom control. It will be great if I could use any of the
existing controls to check for minimum length.

Thanks for your help.

regards,
Abhishek.

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
6329
by: Steve Wylie | last post by:
I am constructing an HTML questionnaire and one of the questions requires people to rate some choices from 1 to 5, where 1 is their favourite and 5 is their least favourite: Car Bus Taxi cab Train Airplane
2
2940
by: Mike Button | last post by:
Hello all, I am really really desperate on what I should do, and I am asking for help from anyone in this newsgroup, here's the situation: I am creating a form that is being run on a server where there is no scripts allowed running (the software is from Opentext called Livelink)- therefore I need javascript to do the tasks listed below: 1. validate the form - this has been completed 2. pop up another window that will go ahead and...
5
24641
by: Krechting | last post by:
Hi ALl, I have a code that checks if the documents in a hyperlink field are still where they should be. I use fileexist(). First I want to filter out all the hyperlink fields that are empty. I open a recordset and browse through all the fields to check for the word file. I cannot filter out the empty fields. I have tried: If Len(.Fields("Link") <> 0 then and: If Not IsNull(.Fields("Link")) then
1
1517
by: Mike Moore | last post by:
Is it better to find the max length of a textbox using the dataset (database length fields) or using the length property of the textbox? Also, which is the best and easiest to do - custom validator or expression validator for max and min length of textbox fields?
2
5911
by: johnb41 | last post by:
I have a simple form that has a bunch of textboxes that show data from a dataset table. When I "Add" a record with BindingManagerBase.AddNew(), all the textboxes go blank, so I can add a new record. If I leave a field totally blank, and then click the Update button (which uses the DataAdapter.Update() command, I get an error saying: "Field 'Orders.Email' cannot be a zero-length string"
3
2665
by: Marc Gravell | last post by:
Kind of an open question on best-practice for smart-client design. I'd really appreciate anyones views (preferably with reasoning, but I'll take what I get...). Or if anybody has any useful links on the subject? (and yes, I have already googled it at length, but still no strong decision) ============= After a long stint of pure-desktop / pure-server applications, I'm currently working on a number of smart-client projects in C# using...
29
2913
by: gs | last post by:
let say I have to deal with various date format and I am give format string from one of the following dd/mm/yyyy mm/dd/yyyy dd/mmm/yyyy mmm/dd/yyyy dd/mm/yy mm/dd/yy dd/mmm/yy mmm/dd/yy
1
2523
by: suchismitaswain | last post by:
Hi, I have a field in jsp page that has some textboxes. but the texboxes are dynamically created depending on the no of rows in a table. When i click the update button in my jsp page it has to get the values in the text boxes and get the total. My java script first checks if the field is valid i.e if there are any textbox in the field. If there are no fields then it set a variable as false. but if there are any fields it takes the length of...
4
2388
by: zelmila19 | last post by:
Hi anyone, Could someone check this program for me, I've given it a go, it runs well but gives me 6 of this warning: warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data Please check this and let me know if I've left out anything or any additions, anything: #include <iomanip> #include <iostream>
0
10589
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10340
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10327
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7625
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6857
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5527
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5663
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4302
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2999
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.