jQuery .numeric 和粘贴内容
.numeric 函数(http://www.texotela.co.uk/code/jquery/numeric/)效果很好,但是当您将内容粘贴到 txtOrderName 字段并退出该字段时,它不会验证。
有谁知道任何修改可以允许 .numeric 函数在粘贴内容后再次运行?
例如,如果我将“4,00”粘贴到 txtOrderPrice 字段中,我不希望显示逗号 (,)。如果您在字段中键入“4,00”(更改为“400”),数字函数将忽略此设置。但了解人们后,他们可能只是将“4,00”粘贴到字段中并将内容填满。
<script type="text/javascript" src="jquery.numeric.js"></script>
$(document).ready(function() {
$(".numeric").numeric();
});
</script>
<input class="numeric" type="text" id="txtOrderPrice" name="txtOrderPrice_name" maxlength="128" />
The .numeric function (http://www.texotela.co.uk/code/jquery/numeric/) works great, but when you paste content into the txtOrderName field and you exit the field it doesnt validate.
Does anyone know any modifications that will allow the .numeric function to be run again after content has been pasted?
For example, if I paste '4,00' into the txtOrderPrice field, I dont want the comma (,) to be displayed. The numeric function ignores this if you type '4,00' in the field (changes to '400'). But knowing people they might just paste '4,00' into the field and stuff things up.
<script type="text/javascript" src="jquery.numeric.js"></script>
$(document).ready(function() {
$(".numeric").numeric();
});
</script>
<input class="numeric" type="text" id="txtOrderPrice" name="txtOrderPrice_name" maxlength="128" />
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它说这是限制:
因此,解决方法是将其连接到 .blur() 或 .focusout() 事件:
http://jsfiddle .net/xFJfP/
it says it's the limitation:
so, the workaround would be to hook it up to either .blur() or .focusout() event:
http://jsfiddle.net/xFJfP/
您可以将
,
替换为.
,如下所示:You could replace the
,
with a.
like so: