473,739 Members | 5,405 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How can i read MaxLength properrty in a JavaScript CustomValidator function

RSB
Hi Everyone,

I have this TextBox with the TextMode="Multi Line". so now it does not
validate the text in the TextBox for the MaxLength
SO i have decided to execute a CustomValidator for this Textbox and run a
CLientSideFunct ion. now i was making this clientsidefunct ion generic so that
i can validate all the other textboxes also. Now to do this i need the
access to the MaxLength Property, which i am not able to read in the Java
Function.. Any suggestion how to do this?

Thanks
RSB
PS this is what i have in the function

function validateLength( oSrc, args)
{
alert("hi");
alert(args.Valu e);
alert(args.maxL ength); ' this does not work
args.IsValid = (args.Value.len gth <= 200);
}
Nov 18 '05 #1
3 5052
waht is this maxlength property ? Is this something you created ?

A multiline textbox is an HTML TEXTAREA tag client side. This tag doesn't
have a maxlength property. Waht is wrong with having the validator tho write
down the length when the javascript is created server side as you seems to
do for now ?

Patrice
--

"RSB" <rs*****@hotmai l.com> a écrit dans le message de
news:7g******** ********@news.c pqcorp.net...
Hi Everyone,

I have this TextBox with the TextMode="Multi Line". so now it does not
validate the text in the TextBox for the MaxLength
SO i have decided to execute a CustomValidator for this Textbox and run a
CLientSideFunct ion. now i was making this clientsidefunct ion generic so that i can validate all the other textboxes also. Now to do this i need the
access to the MaxLength Property, which i am not able to read in the Java
Function.. Any suggestion how to do this?

Thanks
RSB
PS this is what i have in the function

function validateLength( oSrc, args)
{
alert("hi");
alert(args.Valu e);
alert(args.maxL ength); ' this does not work
args.IsValid = (args.Value.len gth <= 200);
}

Nov 18 '05 #2
property MaxLength is available only when you set TextBoxMode to SingleLine
or to Password. so in your case you can not use it
to validate the maxlength you have to check for the input keys - but
actually i won't suggest you - there is a lot of work and it is not a good
approach
i would suggest you create a function just to check if the entered value is
greater than a number that is passed to it as parameter

Regards
Martin

"RSB" <rs*****@hotmai l.com> wrote in message
news:7g******** ********@news.c pqcorp.net...
Hi Everyone,

I have this TextBox with the TextMode="Multi Line". so now it does not
validate the text in the TextBox for the MaxLength
SO i have decided to execute a CustomValidator for this Textbox and run a
CLientSideFunct ion. now i was making this clientsidefunct ion generic so that i can validate all the other textboxes also. Now to do this i need the
access to the MaxLength Property, which i am not able to read in the Java
Function.. Any suggestion how to do this?

Thanks
RSB
PS this is what i have in the function

function validateLength( oSrc, args)
{
alert("hi");
alert(args.Valu e);
alert(args.maxL ength); ' this does not work
args.IsValid = (args.Value.len gth <= 200);
}

Nov 18 '05 #3
asp.net does not render the maxLength attribute when mulitiline is set. in
your code behind use the Attributes method to add the attribute yourself.
the textarea will not honor it of course, but you can access it from your
javascript.

-- bruce (sqlwork.com)


"RSB" <rs*****@hotmai l.com> wrote in message
news:7g******** ********@news.c pqcorp.net...
Hi Everyone,

I have this TextBox with the TextMode="Multi Line". so now it does not
validate the text in the TextBox for the MaxLength
SO i have decided to execute a CustomValidator for this Textbox and run a
CLientSideFunct ion. now i was making this clientsidefunct ion generic so that i can validate all the other textboxes also. Now to do this i need the
access to the MaxLength Property, which i am not able to read in the Java
Function.. Any suggestion how to do this?

Thanks
RSB
PS this is what i have in the function

function validateLength( oSrc, args)
{
alert("hi");
alert(args.Valu e);
alert(args.maxL ength); ' this does not work
args.IsValid = (args.Value.len gth <= 200);
}

Nov 18 '05 #4

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

Similar topics

4
8167
by: hardcoded | last post by:
I have a textbox with TextMode set to MultiLine. I also have the MaxLength set to 255. This maxlength value seems to get ignored as the user can enter unlimited characters. Does the multiline textbox not support maxlength? How can I make the work? TIA
3
1754
by: Ronan Dodworth | last post by:
Hi there I'm having a little bit of a problem with my customvalidator control. The problem is the javascript runs fine on my local webserver IIS but not when I post it to the web hosting server. As it is client side scripting I'm suprised that this is the case as I'm using the same browser IE6 and the same machine to access both. I've included the code below. Can anyone help . I've tried lowering all the security settings for intranet...
5
4156
by: gane kol | last post by:
Hi I have a set of Yes/No radio buttons with textboxes for each. I need to write a common customvalidation function that checks, if radiobutton "yes" is selected, the value in the corresponding textbox should be greater than 0. For eg: IsVM Qty: <radX0Yes> YES <radX0No> NO Qty: <txt00> IsVM1 Qty: <radX1Yes> YES <radX1Yes> NO Qty: <txt11>
1
7782
by: avp | last post by:
Hi, We have an ASP.NET 2.0 (C#) application that has a web form with a CheckBoxList control and a CustomValidator control. The CustomValidator control is used to validate that at least one checkbox is checked in the CheckBoxList control. Everything works fine for the server-side validation. However, we're having difficulties with writing a JavaScript function to perform the same validation on the client-side.
1
5271
by: cemcat | last post by:
Hello, We have an ASP.NET 2.0 (C#) web form that contains a textbox for users to enter multiple e-mail addresses separated by semicolons. We need to validate that each individual e-mail address entered is a valid e-mail address format. We've added a CustomValidator to perform this validation. We have the server-side validation working fine, but now we need to add some client-side validation via JavaScript. We are having difficulties...
0
2183
by: Keith | last post by:
I have a web form that contains a repeater control that is designed to ask like a check book register. Clicking on a certain transaction takes the user to a different .aspx page where it can be edited and then saved. Currently, after saving the edited transaction and returning to the check register, the repeater control table returns to the bottom. I would like the edited transaction to appear in the table instead. I know that a...
0
1891
by: Keith | last post by:
I have a web form that contains a repeater control that is designed to ask like a check book register. Clicking on a certain transaction takes the user to a different .aspx page where it can be edited and then saved. Currently, after saving the edited transaction and returning to the check register, the repeater control table returns to the bottom. I would like the edited transaction to appear in the table instead. I know that a JavaScript...
0
6272
by: rascal_mon | last post by:
I'm new with XML. Please give me some advice. I wonder there are any difference between XML that is automatically generated from ADO and XML file that shows in many textbooks. I found that the formats are a bit difference. At the begining of the one that is automatically generated from ADO is usually like this <xml xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:dt="uuid: C2F41010-65B3-11d1-A29F-00AA00C14882"...
2
1738
by: Nathan Sokalski | last post by:
As we probably know, the MaxLength property of the TextBox control only works when the TextMode property is SingleLine or Password. I want to limit the number of characters a user can enter into a MultiLine TextBox to 250. I figured the best way to do this would be with a RegularExpressionValidator. For my ValidationExpression I figured I would use: ..{0,250} However, the . does not include the \n character. On the page:
0
8969
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8792
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9479
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
9209
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8215
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6754
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
6054
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
4826
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3280
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

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.