用javascript实现文本框中只能输入数字,就一条语句: <input name="username" type="text" οnkeyup="value=this.value.replace(/\D+/g,'')">