jQuery validate rule ONLY AT SUBMIT

后端 未结 6 2209
感动是毒
感动是毒 2020-12-09 02:14

Say i have a form that looks up city, state locations. if the user enters an incorrect city, state, i want the form to be able to check the database against the users input

6条回答
  •  被撕碎了的回忆
    2020-12-09 03:18

    Here's an idea that might work: separately bind the keyup function for your field that you don't want the keyup event to be validated on, and have it not bubble:

    $('#citystateID').bind('keyup',function(){
       return false; 
    });
    

    I couldn't figure out how to bind the validator specific events (focusin and focusout), so it would still run validations whenever focus left your "citystate" input, but it's closer to what you wanted?

    I briefly tested this here: http://jsfiddle.net/svUdp/ seemed to work alright (watch your console to see what happens - lots of events being triggered, but not so many validates).

提交回复
热议问题