c# - Display Dialog Box When User Meets MaxLength of TextBox -
i have asp.net c# application. have textbox has maxlength set of 3000. when user reaches maxlength of 3000 want javascript dialog box open , alter user of this. can't figure out how it. can me? thanks.
from aspdotnet-suresh:
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>limit number of characters in textbox or textarea</title> <script type="text/javascript"> function limtcharacters(txtmsg, charlength, indicator) { chars = txtmsg.value.length; document.getelementbyid(indicator).innerhtml = charlength - chars; if (chars > charlength) { txtmsg.value = txtmsg.value.substring(0, charlength); } } </script> </head> <body> <div style="font-family:verdana; font-size:13px"> number of characters left: <label id="lblcount" style="background-color:#e2eef1;color:red;font-weight:bold;">3000</label><br/> <textarea id="mytextbox" rows="5" cols="25" onkeyup="limtcharacters(this,3000,'lblcount');"></textarea> </div> </body> </html>
Comments
Post a Comment