how to use trigger in Jquery to pass parameter data as well as control (this)

Posted by Shantanu Gupta on Stack Overflow See other posts from Stack Overflow or by Shantanu Gupta
Published on 2010-04-07T22:35:44Z Indexed on 2010/04/07 22:43 UTC
Read the original article Hit count: 224

Filed under:
|

I am trying to use same validation funtion for all my controls. But I dont know much in jquery and not been able to pass event handler to the trigger. I want to pass textbox id to my custom function. How can i do this

<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
    $("#txtFirstName").bind('focusout', function()
   {
   $(this).trigger("customblurfocus",[$(this).val(), $(this).val() + " Required !", "Ok !"]);
   }
  );

  $(this).bind('customblurfocus',function(defaultInputValue,ErrorMessage,ValidMessage)
     {alert($(this).val()); 
     if($(this).val()=="" || $(this).val()==defaultInputValue)
      {
      $(this).val(defaultInputValue);
      $(this).siblings("span[id*='error']").toggleClass("error_set").text(ErrorMessage).fadeOut(3000);  
      }
     else
      {
      $(this).siblings("span[id*='error']").toggleClass("error_ok").text(ValidMessage).show(1000);
      }
     }
   );
    });
</script>

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about jquery-selectors