Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
119
rated 0 times [  126] [ 7]  / answers: 1 / hits: 22946  / 14 Years ago, wed, december 22, 2010, 12:00:00

Hi could someone help me figure out how to stop a function running until a specific number of characters are pressed?



currently using the following function:



$('input#q').keyup


this works as soon as you press any key...


More From » jquery

 Answers
7

Something like this should start firing code after 3 letters have been added:



Live Example



JavaScript



$('input#q').keyup( function() {
if( this.value.length < 4 ) return;
/* code to run below */
$('#output').val(this.value);
});


HTML



<input id=q />
<br /><br />
<input id=output/>

[#94519] Monday, December 20, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
bobbyw

Total Points: 456
Total Questions: 102
Total Answers: 113

Location: Bahrain
Member since Fri, Sep 16, 2022
2 Years ago
;