Note that there are some explanatory texts on larger screens.

plurals
  1. POCustom jQuery validation
    primarykey
    data
    text
    <p>I am trying jQuery validate. My code is:</p> <pre><code>jQuery.validator.addMethod("isOnlyEmail", function(value, element,param) { var emailVal; $.getJSON('get/getAllData.php?operation=email&amp;email='+value, null, function(data) { alert(data); if(data==0) emailVal true; else emailVal false; }); return emailVal; }, "My message"); </code></pre> <p>I want to display my message, if only return value is true. but this code is wrong. My message is displayed continuously.</p> <p>if I change my code as follows:</p> <pre><code>jQuery.validator.addMethod("isOnlyEmail", function(value, element,param) { return false; }, "My message"); </code></pre> <p>my message is displayed.</p> <p>if I change my code as follows:</p> <pre><code>jQuery.validator.addMethod("isOnlyEmail", function(value, element,param) { return true; }, "My message"); </code></pre> <p>my message is not displayed.</p> <p>Any idea?</p> <p><strong>HTML code:</strong></p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt; &lt;title&gt;&lt;/title&gt; &lt;script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"&gt;&lt;/script&gt; &lt;script&gt;window.jQuery || document.write('&lt;script src="js/jquery.js"&gt;&lt;\/script&gt;')&lt;/script&gt; &lt;script language="javascript" type="text/javascript" src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"&gt;&lt;/script&gt; &lt;!-- Bootstrap jQuery plugins compiled and minified --&gt; &lt;script type="text/javascript" src="./js/jquery.validate.js"&gt;&lt;/script&gt; &lt;script&gt; $(document).ready(function(){ jQuery.validator.addMethod("isOnlyEmail", function(value, element,param) { var emailVal; $.getJSON('get/getAllData.php?operation=email&amp;email='+value, null, function(data) { alert(data); if(data==0) emailVal true; else emailVal false; }); return emailVal; }, "My Message"); $("#signupform").validate({ rules:{ email:"isOnlyEmail" }, highlight: function(label) { $(label).closest('.control-group').removeClass('success'); $(label).closest('.control-group').addClass('error'); }, success: function(label) { label .text('OK!').addClass('valid') .closest('.control-group').removeClass('error') .closest('.control-group').addClass('success'); } }); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;input id="email" type="email" name="email" placeholder="email@site.com" /&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p><strong>PHP Code</strong>:</p> <pre><code>&lt;?php require_once("../db/dbconnect.php"); $operation = $_GET['operation']; if($operation == "email"){ $mail=$_GET['email']; $query = "SELECT * FROM ACCOUNT WHERE email='".$mail."'"; $result = execute_query($query); echo mysql_num_rows($result); } ?&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