I am trying to press enter key inside a textbox.

I am currently setting up value in the textbox using below code,

var ifrm = document.getElementById("IPage");
var txtValue = ifrm.contentWindow.document.getElementById("textboxid");
acc2.txtValue = "010";

Now, once this value is set inside textboxid , I want to press the enter key using JavaScript.

How can I achieve it?

1 Answers

0
Community On

Try this and see if it works for you.

<!DOCTYPE html>
<html>
<body>

<textarea id="myInput" value=""></textarea>

<script>
var input = document.getElementById("myInput");
input.addEventListener("keyup", function(event) {
  if (event.keyCode === 13) {
   var myValue = document.getElementById("myInput").value;
   event.preventDefault();
   alert(myValue); //For testing purposes - use this value to call your account number
  }
});
</script>
</body>
</html>

You might have to add some additional code to make sure it doesn't accept anything but an integer or whatnot, but I think the basic concept is there.

Try it here -- https://jsfiddle.net/ger0ab4x/3/