验证一个表单需要干的事情

1. 当元素失去焦点时发生 blur 事件。

$("input").blur(function(){
alert("This input field has lost its focus.");
});

http://www.runoob.com/jquery/event-blur.html

2. 当输入框获取焦点的时候,触发的事件。

$("input").focus(function(){
$("span").css("display","inline").fadeOut(2000);
});

http://www.runoob.com/jquery/event-focus.html

3. 当键盘键被松开时发生 keyup 事件。

$("input").keyup(function(){
$("input").css("background-color","pink");
}); 

http://www.runoob.com/jquery/event-keyup.html

4. 当表单提交的时候触发的事件。

$("form").submit(function(){
alert("Submitted");
}); 

http://www.runoob.com/jquery/event-submit.html

JQuery 的事件列表:http://www.runoob.com/jquery/jquery-ref-events.html

原文地址:https://www.cnblogs.com/liuhongfeng/p/4704222.html