Javascript examples for String Operation:String Replace
Use regex to filter text
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> <textarea id="ta" name="ta" onkeyup="clean('ta')" onkeydown="clean('ta')"></textarea> <script type="text/javascript"> function clean(e) {/* w ww . ja v a 2s . com*/ var textfield = document.getElementById(e); var regex = /[a-zA-Z]/gi; textfield.value = textfield.value.replace(regex, ""); } </script> </body> </html>