How can i read MaxLength properrty in a JavaScript CustomValidator function

  • Thread starter Thread starter Patrice
  • Start date Start date
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
 
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);
}
 
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
 
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)
 
Back
Top