<script type="text/javascript">
$(function(){
var inpuid=$("#UserName1");
var defal=inpuid.val();
inpuid.bind({
//若是是得到焦點,則寫成: focus:function()javascript
//這個是失去焦點
blur:function(){
if($("#UserName1").val()==""){
alert("用戶名不能爲空!");
$("#UserName1").focus();
return false;
}else{
$("#lable2,#lable3").html("");
$("#lable1").html("方法一執行");
var url = "test_json!testjson?username="+$("#UserName1").val();
$.getJSON(url,function(data){
alert(data.msg);
});
}
} } )
});
</script>html