分页栏页码输入框校验

<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该事件来改变自身属性或者直接就不要使用该事件

你可能感兴趣的:(分页)