答案 0 :(得分:0)
有很多方法可以从文本框中删除不需要的字符。一种方法是使用regualr表达式从该值字段中过滤掉任何非字母数字字符,并将过滤后的值放回文本框中,替换/覆盖旧值。
$('#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">