输入金额时处理
处理长度,不允许其他字符
function regInput(reg){
if( reg == "") return false ;
var srcElem = event.srcElement
var oSel = document.selection.createRange()
oSel = oSel.duplicate()
oSel.text = ""
var srcRange = srcElem.createTextRange()
oSel.setEndPoint("StartToStart", srcRange)
var num = oSel.text + String.fromCharCode(event.keyCode) + srcRange.text.substr(oSel.text.length)
event.returnValue = reg.test(num)
}
onkeypress="regInput(/^[0-9]{0,24}(\.?)[0-9]{0,2}$/)"
if( reg == "") return false ;
var srcElem = event.srcElement
var oSel = document.selection.createRange()
oSel = oSel.duplicate()
oSel.text = ""
var srcRange = srcElem.createTextRange()
oSel.setEndPoint("StartToStart", srcRange)
var num = oSel.text + String.fromCharCode(event.keyCode) + srcRange.text.substr(oSel.text.length)
event.returnValue = reg.test(num)
}
onkeypress="regInput(/^[0-9]{0,24}(\.?)[0-9]{0,2}$/)"
走向地狱的途中,不小心走了程序员这条路,路上一个个黑心的老板,和暗无天日的加班,我才发现,通往地狱的路径中,我们这行是最短的。