Problem when I place javascript in $(document).ready
<p>Hi I am having following code working fine when placed without $(document).ready </p>

<pre><code> &lt;asp:TextBox ID="TextBox_FirstName" runat="server"&gt;&lt;/asp:TextBox&gt;
 &lt;asp:TextBox ID="TextBox_LastName" runat="server"&gt;&lt;/asp:TextBox&gt;
 &lt;asp:Button ID="txtSubmit" Text="Validate" runat="server" /&gt;
 &lt;asp:CustomValidator ID="AtLeastOneTextBoxValidator" runat="server" 
        ClientValidationFunction="Validate_Textbox" ValidateEmptyText="true"&gt;
 &lt;/asp:CustomValidator&gt;


function Validate_Textbox(sender, args) {
        var firstName = document.getElementById("&lt;%= TextBox_FirstName.ClientID %&gt;");
        var lastName= document.getElementById("&lt;%= TextBox_LastName.ClientID%&gt;");
        if ((firstName == "") &amp;&amp; (lastName == "")){
              window.alert("Error");
        }
} 
</code></pre>

<p>When I placed this code inside $(document).ready it is giving '<strong>Microsoft JScript runtime error: Object expected'</strong> error.</p>

<pre><code>$(document).ready( function(){
    function Validate_Textbox(sender, args) {
        var firstName = document.getElementById("&lt;%= TextBox_FirstName.ClientID %&gt;");
        var lastName = document.getElementById("&lt;%= TextBox_LastName.ClientID%&gt;");
        if ((firstName == "") &amp;&amp; (lastName == "")){
              window.alert("Error");
        }
    }       
});
</code></pre>
