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

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -