Step 1 :Add a HTML textbox into your Page.
Step 2 :Add this Javascript into your Page.
unicode contains the currently pressed Character Code.
String.fromCharCode(unicode) is used to get the Character currently pressed.
Data contains the particular string in Array char format.
Now get the textbox length and compare with the Data String.
Step 3 :Run the Page.