user enter's the 5digit number into the text field and without pressing any button it must be refelected on the simulator. I know how to write the data into simulator I just wanted to know how to fetch this user data as soon as he enters 5 digits without clicking any button that is, on pressing enter the data in the text field must be fetched.
Asked
Active
Viewed 238 times
-2
-
html, javascript, c#, other languages? need more context to be able to provide you some information – Iwan1993 Jun 10 '15 at 08:40
-
See my answer. Using jquery. – M H Jun 10 '15 at 09:15
-
Please check the check mark next to may answer as this answers your question. – M H Jun 10 '15 at 23:18
-
Sir please tell me how to do this in android – Rashmi Byahatti Jun 11 '15 at 10:43
-
Oh..That is completely different question. This answered your question. Please check the check mark next to my answer. And then take that and ask a new question with that question. We only answer one question per post. – M H Jun 11 '15 at 19:29
1 Answers
0
YOU ASKED: "I just wanted to know how to fetch this user data as soon as he enters 5 digits without clicking any button that is, on pressing enter the data in the text field must be fetched."
HERE IS HOW, using the keypress event. I also limited the text input to 5 characters as well with maxlength="5".
$(document).ready(function() {
$("input").keypress(function(e) {
var key = e.which;
if (key == 13) // the enter key code
{
if ($("input").val().length == 5) {
//you get the value with $("input").val()
alert($("input").val());
}
}
});
});
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
Enter 5 characters: <input type="text" id="input" maxlength="5">

M H
- 2,179
- 25
- 50