1 <SCRIPT LANGUAGE="JavaScript">
2 String.prototype.trim = function()
3 {
4 return this.replace(/(^\s*)|(\s*$)/g, "");
5 }
6 function test(te)
7 {
8 alert (te.trim());
9 alert(te.length);
10 alert(te.trim().length);
11
12 }
13 </SCRIPT>
14 <html>
15 <body>
16 <form name="form1" method="post">
17 <p>
18 <input type="text" id ="te" name="textfield" >
19 </p>
20 <p>
21 <input type="button" name="Submit" value="提交" onClick="test(document.getElementById('te').value)">
22 </p>
23 </form>
24 </body>
25 </html>
26
posted on 2007-02-26 16:27
-274°C 阅读(937)
评论(3) 编辑 收藏 所属分类:
web前端