我只需要在我的文本框中允许字母数字和空格,也可以在粘贴时允许字母数字和空格。输入文本框验证
如果在贴输入 “/stackoverflow.com/#=”我需要stackoverflow.com
任何简单的解决方案,或在线的例子吗?
这是例如工作onkeypress事件
function isNumAlp(event) {
var theEvent = event || window.event;
var rv = true;
var key = (typeof theEvent.which === 'undefined') ? theEvent.keyCode : theEvent.which;
if (key && (key !== 8)) {
var keychar = String.fromCharCode(key);
var keycheck = /[.a-zA-Z0-9, ]/;
if (!keycheck.test(keychar)) {
rv = theEvent.returnValue = false; //for IE
if (theEvent.preventDefault) theEvent.preventDefault(); //Firefox
}
}
return rv;
}
@ThomasRollet我需要为我的输入形式,我不需要特殊字符。 – Pointer
请向我们显示您的代码 –
@ThomasRollet我只有几个文本框的形式 – Pointer