Javascript examples for String Operation:String Replace
Replace space character with slash surrounded by spaces " / "
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://code.jquery.com/jquery-compat-git.js"></script> <script type="text/javascript"> $(window).on('load', function() { $('#field').bind('keyup', function() { var myStr = $(this).val()/* ww w . j a v a 2 s . c om*/ myStr=myStr.replace(/\s+$/g, ' / '); $('#field').val(myStr); }); }); </script> </head> <body> <input type="text" id="field"> </body> </html>