Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery Validate on form submitted by JavaScript
    primarykey
    data
    text
    <p>My form is submitted by a link using JavaScript, but I am also trying to validate the from justing jQuery validate. The validation doesn't work when submitted by the link, but it does if I change the link to a submit button. What am I doing wrong?</p> <p>My form:</p> <pre><code>&lt;form id="findmatch" method="post" action="search"&gt; &lt;div&gt; &lt;label class="formlabel"&gt;Match Type &lt;input type="text" name="matchtype" id="matchtype" class="forminput" /&gt; &lt;/label&gt; &lt;label class="formlabel"&gt;Location (postcode) &lt;input type="text" name="location" id="location" class="forminput" /&gt; &lt;/label&gt; &lt;label class="formlabel"&gt;Radius (miles) &lt;input type="text" name="Radius" id="Radius" class="forminput" /&gt; &lt;/label&gt; &lt;label class="formlabel"&gt;Keywords &lt;input type="text" onblur="javascript:usePointFromPostcode(document.getElementById('location').value, showCompleteLatLng)" onchange="javascript:usePointFromPostcode(document.getElementById('location').value, showCompleteLatLng)" name="keywords" id="keywords" class="forminput" /&gt; &lt;/label&gt; &lt;input id="lat" class="hidden" name="lat" type="text" value="" /&gt; &lt;input id="lon" class="hidden" name="lon" type="text" value="" /&gt; &lt;a href="javascript:document.getElementById('findmatch').submit();" onmouseover="javascript:usePointFromPostcode(document.getElementById('location').value, showCompleteLatLng)" class="submit"&gt;Search&lt;/a&gt; &lt;/div&gt; &lt;/form&gt; </code></pre> <p>And my jQuery is</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function () { $("#findmatch").validate({ rules: { location: "required", Radius: { required: true, digits: true }, keywords: "required" }, messages: { location: "Please enter your postcode", Radius: { required: "Please enter a radius", digits: "Please only enter numbers" }, keywords: "Please enter the keywords you wish to search for" } }); }); &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.
 

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