这是使用 jQuery 的方法:http ://jsfiddle.net/ThiefMaster/UZJn2/
<input type="text" maxlength="1" class="only369" />
$('.only369').keyup(function(e) {
if(this.value != '3' && this.value != '6' && this.value != '9') {
this.value = '';
}
});
Run Code Online (Sandbox Code Playgroud)