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

mod rewrite - Doing external redirect. .htaccess NS flag not working. How to achieve similar results? -

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