Bài đăng

Đang hiển thị bài đăng từ tháng 7 30, 2014

TRANG THAM KHẢO: http://nice-tutorials.blogspot.com/

Trang web tham khảo:  http://nice-tutorials.blogspot.com/

Limit the Number of Characters in a Textarea or Text Field

THAM KHẢO TRÊN:  http://www.mediacollege.com/internet/javascript/form/limit-characters.html This script allows you to set a limit on the number of characters a user can enter into a textarea or text field, like so: (Maximum characters: 100) You have   characters left. Step 1 - Create Function Insert the following code into the page head: <script language="javascript" type="text/javascript"> function limitText(limitField, limitCount, limitNum) { if (limitField.value.length > limitNum) { limitField.value = limitField.value.substring(0, limitNum); } else { limitCount.value = limitNum - limitField.value.length; } } </script> Step 2 - Create Text Area Use the following code to create the form and text area (if necessary, change the name of the form and text area to suit your needs): <form name="myform"> <textarea name="limitedtextarea" onKeyDown="limitText(this.form.limitedtextarea,this.form.countd