执行一个JavaScript函数时,在文本框jQuery的填充? [英] Execute a javascript function when textbox is populated in jQuery?

查看:121
本文介绍了执行一个JavaScript函数时,在文本框jQuery的填充?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何执行一个JavaScript函数在文本框中,填入的文字?文本框与用户隐藏。它将通过USB磁卡刷卡进行填充。

伪code:

 < SCRIPT LANGUAGE =JavaScript的类型=文/ JavaScript的>
    功能MyFunction的(){
        当MyTxtBox填充//执行该功能
    }
< / SCRIPT>
< ASP:文本框的id =MyTxtBox=服务器可见=假/>


解决方案

好像你这样做是在页面加载时。如果你是,这是可行的。

  $(文件)。就绪(函数(){
   如果($('#MyTxtBox)VAL()长度的方式> 0){
      MyFunction的();
   }
});

如果它在变化:

  $(文件)。就绪(函数(){
   $('#MyTxtBox')。改变(函数(){
       如果($(本).VAL()长度的方式> 0){
          MyFunction的();
       }
   });
});

How do I execute a function in JavaScript when a text box is populated with text? The text box with be hidden from the user. It will be populated by a USB magnetic card swiper.

Pseudo code:

<script language="javascript" type="text/javascript">
    function MyFunction() {
        //execute this function when MyTxtBox is populated
    }
</script>
<asp:TextBox id="MyTxtBox" runat="server" Visible="false" />

解决方案

Seems like you're doing this when the page loads. If you are, this would work.

$(document).ready(function(){
   if($('#MyTxtBox').val().length > 0){
      MyFunction();
   }
});

If it's on change:

$(document).ready(function(){
   $('#MyTxtBox').change(function(){
       if($(this).val().length > 0){
          MyFunction();
       }
   });
});

这篇关于执行一个JavaScript函数时,在文本框jQuery的填充?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆