Reputation: 533
How do I not allowed when typing "2" when first typing? Is possible using JavaScript?
<input type="number"/>
Only "2" can not typing when start. Any body help? Thank you.
Upvotes: 0
Views: 100
Reputation: 198314
$('input').keypress(function(evt) {
if (evt.which == "2".charCodeAt(0) && $(this).val().trim() == "") {
return false;
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="number"/>
Upvotes: 1