Reputation: 1
<textarea rows="4" cols="20" onkeyup="this.value=this.value.replace([0-9], '')">
</textarea>
this is my codes now I need to block the input of numbers zero to nine any idea on what to change in my codes
as much as possible I want to insert the code inside the < ....... >
Upvotes: 0
Views: 790
Reputation: 2254
Use a regex. This shows the number, then deletes it. Fiddle
<textarea rows="4" cols="20" onkeyup="this.value=this.value.replace(/\d+/g, '')"></textarea>
Cleaner method: use onkeydown
and return false based on keyCode. Fiddle with onkeydown
<textarea rows="4" cols="20" onkeydown="if((event.keyCode>47&&event.keyCode<58)||(event.keyCode>95&&event.keyCode<106))return false"></textarea>
Note: you have to handle the top row of numbers as well as the keypad in this case, hence the two sets of conditions.
Upvotes: 2
Reputation: 8171
You can also use this code :
<textarea rows="4" cols="20" onkeyup="this.value=this.value.replace(/[0-9]/g, '')"></textarea>
Upvotes: 0