How can i read MaxLength properrty in a JavaScript CustomValidator function

P

Patrice

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
 
R

RSB

Hi Everyone,

I have this TextBox with the TextMode="MultiLine". 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
CLientSideFunction. now i was making this clientsidefunction 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.Value);
alert(args.maxLength); ' this does not work
args.IsValid = (args.Value.length <= 200);
}
 
M

Martin Marinov

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
 
B

bruce barker

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top