duanba4942 2012-09-13 08:40
浏览 164
已采纳

使用onkeyup JS事件检查输入的值是否唯一

I am validating a field called client code for uniqueness...

I have used onkeyup JS event for this purpose. But its not working fine when i type the keys very fast. On this

onkeyup event

i am sending an ajax request to check whether the entered data already exists in the table or not.

Pls help if there is any alternative..

  • 写回答

3条回答 默认 最新

  • dongruo4601 2012-09-13 08:56
    关注

    Your question is quite vague in terms of the actual issue that you seem to be facing. But what I derive from it is that you are firing too many requests as you suggest rapid key presses!


    As you would know, Ajax is like a normal page request, just done async, so it is bound by the same network latency, throughput and round trip constraints.

    A clean way to achieve the functionality you need is to use a technique called throttling. One of the best js plugin for this purpose is located here: http://benalman.com/projects/jquery-throttle-debounce-plugin/ It basically allows you to rate-limit your requests to the server, thus not choking the resources and providing a smooth UI.


    Also, unless you wish to trap certain special keys like <kbd>ESC</kbd>, I would suggest using keypress or keydown events. Can't remember the specific reasoning for it, but just a suggestion.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?