日期:2014-05-16 浏览次数:20453 次
function search(param) { var re=new RegExp("[&,?]"+param+"=[^\\&]*","i"); var str=re.exec(document.location.search); if(str == null || str=="" || str.length==0){ return ""; } else { str = str+""; str = str.split("=")[1]; return str; } }
<input type=file id=a1 style="visibility:hidden"> <input id=a2 type=text readonly> <input type=button value=浏览 onclick="a1.click(); a2.value= a1.value">
<input type="file" style="width: 446px" id="ptlFile" contenteditable="false"/>
String.prototype.trim = function() { return this.replace(/^\s\s*/, '').replace(/\s\s*$/, ''); }
function getBytesLength(str) { return str.replace(/[^\x00-\xff]/g, 'xx').length; }
<textarea onkeyup="this.value = this.value.slice(0, 80)"></textarea> //或者 <textarea onkeyup="this.value = this.value.substring(0, 80)"></textarea>
<textarea rows="3" cols="40" maxlength="200" onkeydown="checklength(this);"> </textarea> // 加上这个方法 function checklength(obj) { var max = obj.maxlength; if(max == null || max == "" || max == undefined) { return; } if(obj.value.length > max) { alert("请不要超过最大长度:" + max); obj.value=obj.value.substring(0,(max-1)); return; } }