Reputation: 153
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" />
Upvotes: 0
Views: 1940
Reputation: 7026
You could replace the ,
with a .
like so:
value.replace(/,/g,".");
Upvotes: 0
Reputation: 10147
it says it's the limitation:
Limitations / Bugs CTRL+A does not select all text. Text pasted via the mouse is not auto-corrected, though a callback can be defined to work around this.
so, the workaround would be to hook it up to either .blur() or .focusout() event:
$(document).ready(function() {
$(".numeric").numeric();
$(".numeric").focusout(function() {
$(this).keyup();
});
})
Upvotes: 2