Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have some javascript that takes data that is being typed into a html text area, and counts the number of characters entered on the keyup event of the textarea. I currently have set the maximum number of characters to a default value in code, ideally I need that value to be easily changed depending on who the user is.

 

I know that I can change the value be introducing a query string variable and examining that variable each time. However I feel that this option is unsafe as the individual user can simple alter the value at random.

 

I have tried to use a textarea, by setting the value in the textarea on the page load event, and then passing the name of the textarea to the javascript on the keyup event of the message textarea. However, when the javascript starts executing, I get an undefined event error. Any suggestions on how I can solve this problem.

 

The javascript method:

function limitText(limitField, limitCount, msgCount, charsCount, txtbox){
}

 

The onkeyup event of the message box:

onKeyUp="limitText(this.form.txtMessage,this.form.count,this.form.MsgNo,this.form.CharsLeft,this.form.sponsor);"

 

Mike55.

A Client refers to the person who incurs the development cost.

A Customer refers to the person that pays to use the product.

------

My software never has bugs. It just develops random features. (Mosabama vbforums.com)

Posted

Dude....

 

How about this...

 

<textarea maxLength="300">

 

You have your textarea element...and a custom attribute of maxlength...

on the server side, just figure out the user's custom setting and set that value

 

<textarea maxLength=<%=textLength%> >

 

...Server code:

 

protected int textLength;

 

private void Page_Load

{

if (user is admin)

textLength = 1000;

else

textLength = 100;

}

 

 

 

Anyway, if you just want to solve your current problem...check for arguments inside the limitText function. You are most likely receiving an undefined error because the function is being ran before one of the params is populated.

 

limitText(...)

{

if (arguments.length < 5) return;

}

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...