سؤال

Am trying to disable open and closed parenthesis for a textbox.

Am succesful in disabling keycode for few characters but not with the one uses SHIFT.

 if(event.keyCode == 57 || event.keyCode == 48)

disables both 9 ,0 along with open and closed parenthesis

if (event.shiftKey) {
            if(event.keyCode == 57 || event.keyCode == 48)
            event.preventDefault();
        }

how do i diable parenthesis alone and not numbers. what is the correct way.

i dont want to use any plugins

Thanks

هل كانت مفيدة؟

المحلول

$('input').on('keypress', function(e) {
    if (e.which == 40 || e.which == 41)
        e.preventDefault();
});

FIDDLE

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top