日期:2014-05-17 浏览次数:20754 次
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>控制textarea的字符个数</title> <style> <!-- form{ padding:0px; margin:0px; font:14px Arial; } input.txt{ /* 文本框单独设置 */ border: 1px inset #00008B; background-color: #ADD8E6; } input.btn{ /* 按钮单独设置 */ color: #00008B; background-color: #ADD8E6; border: 1px outset #00008B; padding: 1px 2px 1px 2px; } --> </style> <script language="javascript"> function LessThan(oTextArea){ //返回文本框字符个数是否符号要求的boolean值 return oTextArea.value.length < oTextArea.getAttribute("maxlength"); } </script> </head> <body> <form method="post" name="myForm1" action="addInfo.aspx"> <p><label for="name">请输入您的姓名:</label> <input type="text" name="name" id="name" class="txt" value="姓名" maxlength="10"></p> <p><label for="comments">我要留言:</label><br> <textarea name="comments" id="comments" cols="40" rows="4" maxlength="50" onkeypress="return LessThan(this);"></textarea></p> <p><input type="submit" name="btnSubmit" id="btnSubmit" value="Submit" class="btn"> <input type="reset" name="btnReset" id="btnReset" value="Reset" class="btn"></p> </form> </body> </html>
------解决方案--------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>电话号码检测 </title> <meta name="Generator" content="EditPlus"> <meta name="Author" content="Dsmart"> <meta name="Keywords" content=""> <meta name="Description" content=""> </head> <body> 电话号码:<input id ="phone&quo