0

Hi in our jquery mobile application there is a registration form where user enters a token. Token can be copied from somewhere. We want that user won't be able to type the token can just copy it in the input. Also when user focus on input then mobile keyboard should not appear. How can this be achieved ?

What i tried Make input disabled then bind a event listener for longpress/taphold, but had difficulty in getting values from clipboard.

Please help !!!!

1 Answers1

0

From this answer. This might help you.

<form>

    <script type="text/javascript">
         function validate(evt) {
               var theEvent = evt || window.event;
               var key = theEvent.keyCode || theEvent.which;
               key = String.fromCharCode(key);
               var regex = /[]|\./;
               if(!regex.test(key)) {
                  theEvent.returnValue = false;
                  if(theEvent.preventDefault) 
                     theEvent.preventDefault();
                  }
         }                       
    </script>

    <input name="input" type="text" onkeypress='validate(event)' value="" />

</form>
Community
  • 1
  • 1
AvenashKrish
  • 343
  • 2
  • 6
  • 20
  • I have seen it but I am not sure its gonna help in mobile as i also don't want popup keyboard when user focuses ..... if I can somehow get clipboard values then my approach could work i tried various things ... none of them are concrete .... – saurabhgupta05085 May 31 '15 at 11:30