js判断字符串中只有数字和小数点Js代码——例子parseFloat("1234blue"); //returns 1234.0 parseFloat("0xA"); //returns NaN parseFloat("22.5"); //returns 22.5 parseFloat("22.34.5"); //returns 22.34 parseFloat("0908"); //returns 908 parseFloat("blue"); //returns NaN我用到的代码:parseFloat($("#inlbl41").val());为了中输入的值在parseFloat()后能获取值手动检验$("#inlbl41").val()字符串中只有数字和小数点,求高手赐教?
<input type ='text' onkeypress = "return check()"><script>function check(){ var _iKeyCode = window.event.keyCode; if ((_iKeyCode < 48 || _iKeyCode > 57) && _iKeyCode!=46) window.event.returnValue = false; return true; }</script> 追问 提示错误:window.event is undefined