母版页性骚扰!!!!!!
<script language= "javascript " type= "text/javascript ">
function regInput(max,obj, reg, inputStr)
{
var docSel = document.selection.createRange()
if (docSel.parentElement().tagName != "INPUT ") return false;
oSel = docSel.duplicate();
oSel.text = " ";
var srcRange = obj.createTextRange();
oSel.setEndPoint( "StartToStart ", srcRange);
var str = oSel.text + inputStr + srcRange.text.substr(oSel.text.length);
if (obj.value.substr(0,1) == "0 ") return false;
if (obj.value> max){
alert( "超出库存数量! ");
obj.value=max;
return false;
}
return reg.test(str)
}
</script>
上面的函数:用户只能输入整数
下面是调用:
<asp:TextBox ID= "txtQuantity " runat= "server "
onKeyPress= "return regInput(20,this,/^[0-9]*$/,String.fromCharCode(event.keyCode)) "
onpaste= "return regInput(20,this,/^[0-9]*$/,window.clipboardData.getData( 'Text ')) "
ondrop= "return regInput(20,this,/^[0-9]*$/,event.dataTransfer.getData( 'Text ')) "
onkeyup= "return regInput(20,this,/^[0-9]*$/,this.value) " Text= ' <%# Eval( "Quantity ") %> '>
</asp:TextBox>
只要放到母版页的子页面下就不起效果
------解决方案--------------------
lishijie910123(没有做不到,只有想不到) ( ) 信誉:100 2007-7-17 23:27:53 得分: 0
母版页中不能放javascript,
必须写在一个js文件中调用才行
lubosun(大白菜) ( ) 信誉:96 2007-7-18 10:09:04 得分: 0
加了母版页,.NET控件的客户端名称都变了,当然会出错呢.
是么?