views:

29

answers:

1

Hi,

I did be glad if someone could help me solve this

I have a user sign up page with username and password choice fields, I'm providing validation and availability asynchronously using event listeners,

    //username
$("#username" ).bind('blur',function(e){
//ajax call 
if (e.target == e.currentTarget) {
       e.stopPropagation();               
       e.preventDefault();
}
    return false;      
       });


//userpassword
$("#userpassword" ).bind('blur',function(e){
//ajax call 
 if (e.target == e.currentTarget) {
       e.stopPropagation();               
       e.preventDefault();
       }
       return false;
 });

however on blur(ring) the child password field the ajax call on the username field is also activated, I suspect that this is a bubbling issue but somehow stopPropagate() is not working

Thanks

//adding the mark up

            <form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">
 <ul>
            <li>
              <input name="user[name]" type="text" id="username" accesskey="u" value="" maxlength="15" autocomplete="off" class="username" /></li>
<li><input name="user[password]" type="text" id="userpassword" accesskey="p" value=""  autocomplete="off" class="userpassword" /></li>
</ul>
</form>
+1  A: 

Description of stopPropagation from jQuery API...

Prevents the event from bubbling up the DOM tree, preventing any parent handlers from being notified of the event.

A textbox cannot be the parent of another textbox, so this is not going to work.

Josh Stodola
hi, so what could account for the bubbling effect?If it's not a parent/child affair then they are adjacent right?any ideas?thanks
Digital Craft Studios
I don't believe there is any bubbling. It just doesn't make sense for `blur` to bubble.
Josh Stodola
Having said that, you have a problem elsewhere in the code.
Josh Stodola
k, looking into it, piece meal, thanks
Digital Craft Studios
fixed it, did a rewrite of the code entirely in jQuery and well it just worked, wasn't a bubbling problem afterallthanks
Digital Craft Studios