分页栏页码输入框校验

<input type="text" id="pageNo" name="pageNo" class="inputPage2" 
       onkeyup="var tmpval = this.value.replace(/\D/g,'');if(this.value != tmpval){this.value=tmpval;}if(this.value>${page.totalPages}){this.value=''}"  
       onblur="var tmpval = this.value.replace(/\D/g,'');if(this.value != tmpval){this.value=tmpval;}if(this.value>${page.totalPages}){this.value=''}" 
       oninput="var tmpval = this.value.replace(/\D/g,'');if(this.value != tmpval){this.value=tmpval;}if(this.value>${page.totalPages}){this.value=''}" 
       onpaste="var tmpval = this.value.replace(/\D/g,'');if(this.value != tmpval){this.value=tmpval;}if(this.value>${page.totalPages}){this.value=''}" 
       onafterpaste="var tmpval = this.value.replace(/\D/g,'');if(this.value != tmpval){this.value=tmpval;}if(this.value>${page.totalPages}){this.value=''}" 
       onpropertychange="var tmpval = this.value.replace(/\D/g,'');if(this.value != tmpval){this.value=tmpval;}if(this.value>${page.totalPages}){this.value=''}" />

注意:使用onpropertychange(ie特有)事件时注意,当使用事件来校验输入框自身并改变自身属性时,可能会形成内存溢出,由于当改变自身属性时同时触发onpropertychange事件,而后就会致使死循环,能够经过以上事件调用顺序以及改变属性以前先判断自身属性是否改变,若是不变就不执行,这样可避免死循环。没有必要不要使用 onpropertychange该事件来改变自身属性或者直接就不要使用该事件this

相关文章
相关标签/搜索