如下是例子的部分代码(个方法都可以)
<script type="text/javascript">
$(document)ready(function() {
onlyNum("test");
}
//文本框只能输入数字不能输入小数点和字母 by john
function onlyNum(id){
$("#"+id)keydown(function(event)
{ var keyCode = eventwhich;
if (keyCode == || keyCode == || keyCode == || keyCode == || (keyCode >= && keyCode <= ) || (keyCode >= && keyCode <= ) )
{ return true; }
else { return false } }
)focus(function()
{ thisstyleimeMode = disabled; }
);
}
//文本框只能输入数字和小数点不能输入字母 by john
function pageOnlyNumber(evt){
evt = (evt) ? evt : windowevent;
keyCode = evtkeyCode ? evtkeyCode : (evtwhich ? evtwhich :evtcharCode);
if((keyCode < || keyCode > ) && keyCode != && keyCode != )
{
if(windowevent){
windoweventreturnValue = false;
}
else{
evtpreventDefault();
}
}
}
</script>
<input type="text" id="APPLY_FEE_RATE" name="APPLY_FEE_RATE" onkeypress="pageOnlyNumber(event)" maxlength="" size="" value= class="validate[funcCall[checkFunction]]" />
<input type="text" name="test" id="test" value= />