在ctrl + v之后验证文本框值 [英] Validate the textbox value after ctrl+v
本文介绍了在ctrl + v之后验证文本框值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我必须验证文本框只输入字母数字字符。
函数validateAlphaNumeric(evt,txtbox)将在文本框上触发onkeypress事件。
以下是用javascript编写的函数。
但我无法获得该值的值如果我按Ctrl + V,则为文本框。我需要验证用户是否粘贴。
任何人都可以建议我吗?
Hi,
I have to validate the textbox to enter only alpha numeric characters.
The function validateAlphaNumeric(evt, txtbox) will fire onkeypress event on textbox.
Below is the function written in javascript.
But i am not able to get the value of the textbox if i do Ctrl+V. i need to validate if user pastes.
Can any one suggest me on this?
function validateAlphaNumeric(evt, textBox) {
/* File Description : Numbers,Characters,Hyphen(-),Slash(/)and Space */
var charCode;
charCode = (evt.which) ? evt.which : window.event.keyCode;
if (charCode >= 97 && charCode <= 122 || charCode >= 65 && charCode <= 90 || charCode == 8 || charCode >= 48 && charCode <= 57 || charCode == 45) {
return true;
}
else {
var errorMsg = document.getElementById(textBox.id + 'Error');
if (errorMsg != null) {
errorMsg.innerText = "Please Enter Alpha – Numeric Characters only";
}
return false;
}
}
提前谢谢
Thanks in advance
推荐答案
您可以阅读这篇文章 - Javascript密钥事件测试脚本 [ ^ ]。获取Ctrl + V的值。
You can read this article - Javascript Key Event Test Script[^]. Get the values of Ctrl + V.
限制粘贴到文本框中。
< asp:textbox id =txtrepass runat =servercssclass =txtbx2width =164pxtextmode =Passwordoncopy =return falseonpaste =return falseoncut =return falseonkeydown =return DisableCopyPaste(event)onmousedown = return DisableCopyPaste(event)>
restrict to paste in textbox .
<asp:textbox id="txtrepass" runat="server" cssclass="txtbx2" width="164px" textmode="Password" oncopy="return false" onpaste="return false" oncut="return false" onkeydown="return DisableCopyPaste(event)" onmousedown="return DisableCopyPaste (event)" >
在我的代码中我有这个...
所以它可以帮助你...
..
In My Code I Had this ...
So It Might Help You..
..
这篇关于在ctrl + v之后验证文本框值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文