Can I preventDefault(); inside of an ajax callback?

前端 未结 3 1867
陌清茗
陌清茗 2021-01-11 13:58

I\'m doing some form validation, and I\'m having trouble with what I\'m trying to accomplish. I want to be able to validate my zip code on blur of the field, but also call t

3条回答
  •  忘掉有多难
    2021-01-11 14:17

    No, by the time the callback from the AJAX event fires, the event will have already bubbled and the form submitted. One way you could accomplish this is cancel the form from submitting and then submit it manually if it passes the requirements from the AJAX request.

提交回复
热议问题