文字列を貼り付けることができないようにしたい(。| ")キーボードのキーに関する研究を行っていましたが、ユーザータイプのときに機能しますが、どうやって貼り付けを防止しますか?JQueryのonpasteイベントは、| 、。/
ここはここTesting here
jsfiddleである私のJavaスクリプトは、あなたが以下のようにbind
とともにsetTimeout
を使用して、正規表現を使って文字を削除することができます
$("[name='search']").on({
keydown: function(e) {
if (e.which === 32 || e.which === 220) {
e.preventDefault();
var v = this.value,
s = this.selectionStart;
this.value = v.substr(0, s) + '' + v.substr(s, v.length);
}
if (e.which === 55) {
e.preventDefault();
var v = this.value,
s = this.selectionStart;
this.value = v.substr(0, s) + '7' + v.substr(s, v.length);
}
},
// Here is the paste function but i no sure how to write it
paste: function(e) {
var s = this;
setTimeout(function() {
// here i no sure how to do it
});
}
});
正規表現 'onInputChange'を実行することがあります。 –
特定の文字をチェックする方法や文字列から特定の文字を削除する方法を調べることは難しくない – charlietfl
['on()'](http://api.jquery.com/on/)の使い方についてはjQueryのドキュメントを読むべきだと思います。 –