系統有個欄位,做爲參數設置,限制用戶只能輸入大於0的正整數:ide
<input type="text" name="non" ng-model="non" onpaste="return false;" onkeyup="if ( this.value.length == 1 ) { this.value = this.value.replace(/[^1-9]/g, '') } else { this.value = this.value.replace(/\D/g, '') }" onafterpaste="if ( this.value.length == 1) { this.value = this.value.replace(/[^1-9]/g, '0') } else { this.value = this.value.replace(/\D/g, '') }" />
上面有一個onpaste屬性,便是說,此文本框不接受粘貼數據。this