title: jquery masked input with asp.net control problem
body: <p>I have problem while using jquery maskedinput with asp.net textbox.
  I have a check box that when I check will set a mask to the textbox and when uncheck it change the mask. the problem that when the focus is lost before the mask completed to be filled the text box will empty.</p>
  
  <p>how can I fix the problem???</p>
  
  <p>here is my code:</p>
  
  <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head runat="server"&gt;
      &lt;title&gt;Untitled Page&lt;/title&gt;
  
  
  
      &lt;script src="js/jquery-1.4.1.js" type="text/javascript"&gt;&lt;/script&gt;
  
  
      &lt;script src="js/jquery.maskedinput-1.2.2.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;script type="text/javascript"&gt;
  
  
           function mycheck() {
  
              if ($('#&lt;%=chk.ClientID %&gt;').is(':checked')) 
  
                  {
                          $("#&lt;%=txt.ClientID %&gt;").unmask();
                          $("#&lt;%=txt.ClientID %&gt;").val("");
                          $("#&lt;%=txt.ClientID %&gt;").mask("999999999999");
  
                      } 
                      else
                       {
                          $("#&lt;%=txt.ClientID %&gt;").unmask();
                          $("#&lt;%=txt.ClientID %&gt;").val("");
                          $("#&lt;%=txt.ClientID %&gt;").mask("(999)999-9999");
  
                      }
  
  
  
  
  
  
          }
      &lt;/script&gt;
  
      &lt;style type="text/css"&gt;
          #form1
          {
              margin-top: 0px;
          }
      &lt;/style&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form id="form1" runat="server"&gt;
          &lt;asp:ScriptManager ID="ScriptManager1" runat="server" /&gt;
          &lt;div&gt;
  
          &lt;p&gt;
              &lt;asp:CheckBox ID="chk" runat="server" CssClass="kk" 
                  onclick="mycheck()"  /&gt;
          &lt;/p&gt;
  
           &lt;p&gt;
             &lt;asp:TextBox ID="txt" runat="server" CssClass="tt"  &gt;&lt;/asp:TextBox&gt;
  
          &lt;/p&gt;
  
  
          &lt;/div&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>