Note that there are some explanatory texts on larger screens.

plurals
  1. POSyntax error with parseJSON during unobtrusive validation
    primarykey
    data
    text
    <p>My MVC app is generating the following HTML which causes a Javascript syntax error upon submission (I'm not typing anything into the two text boxes). Here's the generated HTML and the submit handler:</p> <pre><code>&lt;form action="/UrIntake/Save" id="UrIntakeForm" method="post"&gt; &lt;input data-val="true" data-val-length="The field LastName must be a string with a maximum length of 50." data-val-length-max="50" data-val-required="The LastName field is required." id="FormSubmitter_LastName" name="FormSubmitter.LastName" type="text" value="" /&gt; &lt;input data-val="true" data-val-length="The field FirstName must be a string with a maximum length of 50." data-val-length-max="50" data-val-required="The FirstName field is required." id="FormSubmitter_FirstName" name="FormSubmitter.FirstName" type="text" value="" /&gt; &lt;div id="SubmissionButtons" class="right"&gt; &lt;input type="button" onclick="SubmitForm()" value="Submit" /&gt; &lt;input type="button" onclick="CancelForm()" value="Cancel" /&gt; &lt;/div&gt; &lt;/form&gt; function SubmitForm() { $("#UrIntakeForm").valid(); . . . </code></pre> <p>This is the jQuery code where the syntax error is occurring (v1.9.0). "data" is undefined and the "return" line is where the error occurs:</p> <pre><code>parseJSON: function( data ) { // Attempt to parse using the native JSON parser first if ( window.JSON &amp;&amp; window.JSON.parse ) { return window.JSON.parse( data ); } </code></pre> <p>Presumably, I don't have to enter anything into the text boxes (and should then get the "field is required" message). Is this what's causing the error? That doesn't make sense, but I don't see what else it could be.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload