M
M
Mr_Romanov2016-08-04 15:45:51
MySQL
Mr_Romanov, 2016-08-04 15:45:51

How to make a function that will determine what the word is entered?

Hello everyone, the question is probably banal but I could not google it.

Here is a small piece of code:

$(".search").keyup(function(event) {
    event.prepventDefault;
    if ($(this).val().length>=2) {
////что-то происходит


From it it is clear that when the user starts working in the input with the search class, we begin to process this event.
Well, if the user has entered more than 2 characters, we do something.

And so, an essence of a question how to make definition that the user entered a word entirely?

As you understand, this is a search, and so I don’t want to pull the search module every time a character is entered.

I have 2 options in my head, one is to wait after the user's activity for a couple of milliseconds after he stopped printing, and the second is to process words only after spaces except the first one.

Are my thoughts correct? Or is it better to handle this on the receiving script side?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
res2001, 2016-03-31
@res2001

Something like this:

select distinct uid_table_1_item 
from table3 t3
left join table3 t3n on t3n.uid_table_2_item not in (массив uid_table_2_item) and t3.uid_table_1_item = t3n.uid_table_1_item
where t3.uid_table_2_item in (массив uid_table_2_item)
and t3n.uid_table_2_item is not null

A
Alexey Yarkov, 2016-08-04
@Mr_Romanov

event.pre p ventDefault;
And don't reinvent the wheel

H
hetzerok, 2016-08-04
@hetzerok

In any case, you need to set a delay so as not to load the server with unnecessary requests, and how to build further processing is a purely personal matter.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question