requiredfieldvalidator cause javascript errorhttp://forums.asp.net/t/1773269.aspx/1?requiredfieldvalidator+cause+javascript+errorSat, 17 Mar 2012 12:07:21 -040017732694848463http://forums.asp.net/p/1773269/4848463.aspx/1?requiredfieldvalidator+cause+javascript+errorrequiredfieldvalidator cause javascript error <pre class="prettyprint">I use a requiredfieldvalidator, but it always cause javascript error: a yelloew &quot;!&quot;.</pre> <pre class="prettyprint">When open the client side sourcecode: the error code location is: <span style="text-decoration: underline;">WebForm_AutoFocus(<span class="JS_STR">'cqidTextBox'</span>);<span class="JS_COM">//]]&gt;</span></span></pre> <pre class="prettyprint">pls help me. thanks a lot!</pre> <pre class="prettyprint">my .aspx code:</pre> <pre class="prettyprint">&lt;body&gt; &lt;form id="form1" runat="server"&gt; &lt;asp:FormView ID="FormView1" runat="server" DataKeyNames="id" DefaultMode="Insert" DataSourceID="SqlDataSource1" EnableModelValidation="True"&gt; &lt;InsertItemTemplate&gt; uid: &lt;asp:TextBox ID="uidTextBox" runat="server" Text='&lt;%# Bind("uid") %&gt;' /&gt; &lt;br /&gt; cqid: &lt;asp:TextBox ID="cqidTextBox" runat="server" Text='&lt;%# Bind("cqid") %&gt;' /&gt; &lt;asp:RequiredFieldValidator ID="RFV1" runat="server" Display="Dynamic" ControlToValidate="cqidTextBox"</pre> <pre class="prettyprint"> SetFocusOnError="true" Text="errors" ErrorMessage="RequiredFieldValidator"&gt;&lt;/asp:RequiredFieldValidator&gt; </pre> <pre class="prettyprint">&nbsp;</pre> <pre class="prettyprint"> &lt;asp:Button runat="server" CausesValidation="true" CommandName="Insert" Text="chacha" /&gt; &lt;/InsertItemTemplate&gt; &lt;/asp:FormView&gt; &lt;asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="&lt;%&#36; ConnectionStrings:nx02dbConnectionString %&gt;" InsertCommand="INSERT INTO [tfhouse_zjs] ([uid], [cqid])" &gt; &lt;InsertParameters&gt; &lt;asp:Parameter Name="uid" Type="Int32" /&gt; &lt;asp:Parameter Name="cqid" Type="Int32" /&gt; &lt;/InsertParameters&gt; &lt;/asp:SqlDataSource&gt; &lt;/form&gt; &lt;/body&gt;</pre> 2012-02-24T05:11:22-05:004848498http://forums.asp.net/p/1773269/4848498.aspx/1?Re+requiredfieldvalidator+cause+javascript+errorRe: requiredfieldvalidator cause javascript error You're using the wrong ControlToValidate: ControlToValidate=&quot;cqidTextBox&quot; should be &quot;uidTextBox&quot;. [edit] either OP updated his previously posted code, or I'm clearly going blind. 2012-02-24T05:32:28-05:004848552http://forums.asp.net/p/1773269/4848552.aspx/1?Re+requiredfieldvalidator+cause+javascript+errorRe: requiredfieldvalidator cause javascript error <p>thanks! but I indeed want to validate &quot;cqidTextBox&quot;.</p> <p>I thinks the problem is not relate to this. maybe relate to the setfousonerror?</p> 2012-02-24T05:59:09-05:004858376http://forums.asp.net/p/1773269/4858376.aspx/1?Re+requiredfieldvalidator+cause+javascript+errorRe: requiredfieldvalidator cause javascript error <p>Hi,</p> <p>I have test the similar scenery but the SetFocusOneError dont cause an error. You can set break point and debug your code. You can also use FireBug to debug your javascript. Then you will know what has caused the error.</p> <p><a href="http://getfirebug.com/javascript">http://getfirebug.com/javascript</a></p> 2012-03-01T08:02:34-05:004885230http://forums.asp.net/p/1773269/4885230.aspx/1?Re+requiredfieldvalidator+cause+javascript+errorRe: requiredfieldvalidator cause javascript error <p>thanks!</p> 2012-03-17T12:07:21-04:00