You might have witnessed at some places where numbers are allowed, paste feature doesn’t work either in Internet Explorer or in Chrome/Firefox AND in some particular scenarios, paste feature worked fine in Internet Explorer/Chrome but not in Firefox AND paste alphabets along numbers too in numbers only text field . After coding/debugging/testing, finally come up with below written code that totally runs smoothly even on Internet Explorer > 6.0.
Using the Code
So this function will check the input value on keypress or when you move focus to other field or when you press ctrl + v in target input area, you just need to place the code in:
Points of Interest
This snippets have been tested on Chrome/Firefox/Safari/Internet Explorer > 6.0, value in
setTimeout function can be changes as per need along with regex expression.
- Version 1.0
Code is available @ https://github.com/m-hassan-tariq/jquery-NumberValidationOnCopyPaste
About the Author