Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can use errorLabelContainer configuration option.. define a <strong>div with an id like errorMessages</strong> and then change your validate method call as follows: </p> <pre><code>$("form").validate({ errorLabelContainer: $("#errorMessages"), rules: ..... your rules </code></pre> <p>Now all the error messages will be displayed in the div. <strong>Edit: Updated the answer below to reflect the updates to the question:</strong> To change the location of error messages displayed, I can think of using the errorPlacement config parameter. You can use something like: Define a div or a p and keep appending the messages for the checkboxes to this element.</p> <pre><code>$("form").validate({ errorPlacement:function(error,element) { if (element.attr("name") == "selectItems") { //Add Code to append the error message to a predefined element $("#errorDiv").html(""); $("#errorDiv").append("&lt;YOUR_CUSTOM_MESSAGE&gt;"); } else { error.insertAfter(element); } }, rules: ..... your rules }); </code></pre> <p>jsFiddle URL: <a href="http://jsfiddle.net/Z8hWg/28/" rel="nofollow">http://jsfiddle.net/Z8hWg/28/</a></p> <p><strong>EDIT:</strong> Change your javascript to as follows:</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function(){ var formValidator = {}; $("#Date").datepicker(); formValidator = $("#form1").validate({ errorPlacement:function(error,element) { if (element.attr("name") == "selectedItems") { //Add Code to append the error message to a predefined element $("#errorDiv").html("Select at least one vehicle"); } else { error.insertAfter(element); } }, rules: { avgTime:{ required:true, number:true }, selectedItems: { required:true }, Date:{ required:true, date:true } }, //onclick: true, submitHandler: function(form) { $("#errorDiv").html(""); form.submit(); } }); $("input[name=selectedItems]").bind("change", function() { var me = $(this); var scoper = me.parent().parent(); var otherInputs = $("input[name^=mileage]", scoper); otherInputs.attr("disabled", !this.checked); otherInputs.attr("value",""); if (this.checked) { otherInputs.addClass('required number'); $("#errorDiv").html(""); } else { otherInputs.removeClass("required number"); } formValidator.element("input[name=selectedItems]"); }); }); &lt;/script&gt; </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. 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.
 

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