Reputation: 9683
Now I am developing a bar code based attendance system . Any there any javascript event can solve once the text field has detected the value has 10 characters, the text field will be fired and i can able to get the value.
Is there any solution ?
Upvotes: 0
Views: 122
Reputation: 7273
you can check the length of the text input box value on every keypress and make a function call when its the 10th character.
Upvotes: 0
Reputation: 166071
I'm not sure what you mean by "the text field will be fired", but you can find out when the 10th character is entered by binding to the keyup
event:
document.getElementById("example").onkeyup = function() {
if(this.value.length === 10) {
console.log("ok");
}
};
It would be better to use addEventListener
or attachEvent
rather than setting the onkeyup
property, but I'll leave that up to you.
Here's a working example.
Upvotes: 2