Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There is nothing wrong with your error placement code. The majority of your issue was being caused by invalid HTML and missing rules. (<em>I would not use a <code>table</code> for a <code>form</code> layout... there are better, more modern ways to do such layouts.</em>)</p> <hr> <p><strong>Root causes:</strong></p> <p><strong>1)</strong> You've repeated <code>id="tris"</code> on multiple elements which is invalid HTML and breaks the code. Elements with duplicate <code>id</code>'s are ignored. Use <code>class</code> instead.</p> <p><strong>2)</strong> You've failed to define any rules for those four additional fields. So of course, no errors will display anywhere.</p> <hr> <p><strong>Good idea to fix:</strong></p> <p><strong>3)</strong> Remove all of your trailing commas. Although this only breaks the code in older versions of Internet Explorer, leaving trailing commas is a sloppy coding practice.</p> <p><strong>4)</strong> You were missing the last <code>&lt;/td&gt;</code> tag in the last <code>&lt;tr&gt;&lt;/tr&gt;</code> of your <code>table</code>.</p> <p><strong>5)</strong> You do not need to specify a custom <code>errorPlacement</code> callback function if <code>error.insertAfter(element)</code> is the only code within. Since this is just the default code of the plugin, it's ok to remove <code>errorPlacement</code> from your plugin options.</p> <hr> <p><strong>Working Demo: <a href="http://jsfiddle.net/9bRXd/" rel="nofollow">http://jsfiddle.net/9bRXd/</a></strong></p> <pre><code>jQuery(document).ready(function ($) { $('#form_register').validate({ rules: { ragsoc: { required: true, minlength: 2 }, piva: { required: true, digits: true }, codfisc: { required: true }, gruppo: { required: true }, insegna: { required: true }, rapporto: { required: true } }, errorElement: "div", messages: { ragsoc: "Inserire la ragione sociale.", piva: "Solo numeri accettati.", gruppo: "inserire un valore." } }); }); </code></pre>
    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.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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