Javascript禁用用于更改密码文本框的空格键
问题描述:
,大家好,
var veri = {
YeniSifreTextBox: $('#YeniSifreTextBox_I').val(),
YeniSifreTekrarTextBox: $('#YeniSifreTekrarTextBox_I').val(),
};
if (veri.YeniSifreTextBox == '' || veri.YeniSifreTekrarTextBox == '') {
alert("Password Can not be empty!");
}
else if (veri.YeniSifreTextBox != veri.YeniSifreTekrarTextBox) {
alert("Passwords dont not match !");
}
我可以控制密码不能为空,并且密码与以上代码不匹配.
I can control password can not be empty and passwords dont not match with above codes.
我想在用户输入密码时禁止输入空格键.
I want to disable to enter space key while user write password.
用户切勿在2个文本框内使用键盘上的空格.
User must never use space in keyboard inside of 2 textboxes.
1.textbox YeniSifreTextBox_I
1.textbox YeniSifreTextBox_I
2.textbox YeniSifreTekrarTextBox_I
2.textbox YeniSifreTekrarTextBox_I
答
您可以使用下面的javaScript代码来阻止空格键
You can use the below javaScript code to block the space key,
function RestrictSpace() {
if (event.keyCode == 32) {
return false;
}
}
HTML
<textarea onkeypress="return RestrictSpace()"></textarea>
希望这对您有所帮助.