- 已关闭**。此问题需要details or clarity。当前不接受答案。
- 想要改进此问题?**添加详细信息并通过editing this post阐明问题。
13小时前关门了。
Improve this question
当我从用户输入,我想让用户明白,他们应该键入的东西开始与"TR"。这就是为什么我想要一个输入像下面的图像。如果有人粘贴或键入的东西开始与"TR",我想防止他们不要"TRTR"。
我的意思不是"占位符"。有没有办法做到这一点?你可以给建议使用输入id选择器。
enter image description here
$("#IBAN").val("TR"); document.getElementById('IBAN').addEventListener('input', function(){ $("#IBAN").bind("paste", function(e){ var iban = $('#IBAN').val(); // access the clipboard using the api var pastedData = e.originalEvent.clipboardData.getData('text'); if (this.value.length >=
1条答案
按热度按时间svmlkihl1#
这应该可以让你开始。当输入字段至少有2个字符并且不是以"TR"开头,或者以"TRTR"开头时,它会显示一个警告。