javascript - jQuery - How to restrict input values for text box -


i want restrict input in textbox either 'y' or 'n' (any case). how can done in jquery.

i'm pretty sure if keydown returns false, input not allowed. can grabbing key code event object. doesn't prevent doing things copy/pasting value text box, though. better option select or radio button if want restrict user's input.

$("#some-selector").bind("keydown", function (e) {   return e.keycode == 89 || e.keycode == 78 }); 

Comments

Popular posts from this blog

python - Does anyone know how to configure the hunpos wrapper class on nltk? -

mysql - How to insert just year and month into date field? -