Reputation: 1086
While copy pasting a text from MS Word to html textbox, the bullet appends in the text box. How to remove it using Jquery/Javascript ?
Upvotes: -3
Views: 596
Reputation: 12737
There are many ways to remove the unwanted characters from a textbox. One way is to use regualr expression to filter out any non-alphanumberic characters from that value field and put the filtered value back into the textbox, replacing/overwriting the old value.
$('#my_textbox').keyup(function() {
//this code will be triggered after each keystroke inside the textbox
// alternatively, you may want to only trigger it after blur/change/etc
var cleaned = $(this).val().replace(/^\s*[o\W]\s+/g, '');
//removes any letter 'o' followed by spaces
//removes any non-alphanumeric followed by spaces
$(this).val(cleaned);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<h3>Paste something here with a bullet point</h3>
<input type="text" id="my_textbox">
Upvotes: 0