JQuery.validate - one rule on blur only; the rest should be normal?

前端 未结 2 2059
清歌不尽
清歌不尽 2020-12-01 23:37

I\'ve worked on a fiddle to show the simple validation that I\'m trying to do for my user ID field:

  1. Make it required (validate as aggressively as possible)
2条回答
  •  一整个雨季
    2020-12-01 23:53

    Quote Title: "one rule on blur only; the rest should be normal?"

    No, the various triggering events, like onfocusout, onkeyup, etc., are triggered on a "per field" basis. You cannot have one rule on a field, say min, triggered normally on all events, while another rule for the same field, say remote, is triggered only by onfocusout. (You can, however, have different events for different fields).

    In most of the SO threads on this topic I've seen, the user will disable onkeyup in order to prevent the constant premature triggering of the remote rule. When testing a re-captcha code, for example, disabling onkeyup is required as a new code is generated every time one fails.

提交回复
热议问题