javascript - Cursor position is changing while any new new value entered in a textbox -


definition: have textbox has maxlength of 11 characters. if try enter value in middle of textbox, cursor position moved automatically end position. please me set cursor position fixed.

note: function used textbox allows alphanumeric value.

here code

<!doctype html> <html> <body> <script> //function alphanumberic validation function alphanumericonly(i){ if(i.value != null)      {         i.value = i.value.replace(/[^\w]+/g, '');       }     } </script> <input type="text" maxlength="11" id="policyorbondnum" onkeyup="alphanumericonly(this);" /> </body> </html> 

try-

<input type="text" maxlength="11" id="policyorbondnum" onkeyup="alphanumericonly(this);" style="text-align: right; padding-right: 50px;"/> 

Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -