开发者

JQuery .blur not triggered

I am trying to (server-)validate an input field when it loses its focus. But nothing happens when the input field loses its focus, alert is not triggered.

My code, php-file:

<?xml version="1.0" encoding="iso-8859-1"?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<?php  header('Content-Type: text/html; charset=ISO-8859-1');
header('Access-Control-Allow-Credentials: true');
header('Access-Control-Allow-Origin: *');
header('Access-Control-Origin: *');?>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
        <script language='javascript' type='text/javascript' src="jquery-1.6.2.min.js"><开发者_开发技巧/script>
        <script language='javascript' type='text/javascript' src="smicadminjavascripts.js"></script> 

        <title>Service Management In the Cloud - Administration</title>

    </head>
    <body>
        <div id="adminmenu">
            <a id="agents" class="adminmenu_items">Agenter</a></br>
            <a id="customer" class="adminmenu_items">Kunder</a></br> 
            <a id="misc" class="adminmenu_items">&Ouml;vrigt</a></br> 

        </div>
        <div id="adminarea">

        </div>
    </body>
</html>

Upon loading the side, I will add the form to the div id="adminarea"

Javascript file:

$(document).ready(function() {       

    $("#username_ID").blur(function(data){
            alert("BLUR"); 
    });

    $.get("registeraccount.php", function(data){
         $("#adminarea").html(data);
    });               

            $("#registerform").live("submit", function(e){
                    e.preventDefault();
                $.post("registeraccount.php",$(this).serialize(),function(msg){

                alert(msg);
        });
       });

  });

Other scripts in the .ready function works properly.

What is the problem and how can I fix it?


It works for me

http://sandbox.phpcode.eu/g/ca2bb.php

  • Click on username
  • Get back to my post
  • Alert fired!

For your problem:

Include jquery :)

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>


You can use .focusout() and don't forget to include jquery library.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜