Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript disable space key for change password textboxes

,Hi all,

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.

User must never use space in keyboard inside of 2 textboxes.

1.textbox YeniSifreTextBox_I

2.textbox YeniSifreTekrarTextBox_I

like image 381
user2706372 Avatar asked Dec 11 '22 11:12

user2706372


1 Answers

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>

Hope this helps you.

like image 176
Ashis Kumar Avatar answered Dec 28 '22 09:12

Ashis Kumar