Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to not show Jquery Tooltip if the email has not been taken
    primarykey
    data
    text
    <p>I'm currently trying to implement a feature to check if an email has already been taken when a first time user registers for my site. I'm trying to do this with AJAX and use the jQuery tooltip (http://flowplayer.org/tools/tooltip/) plugin to display the message if the e-mail has in fact been taken.</p> <p>I don't want to display any message if the e-mail is not taken and don't want the user to be aware of the fact that I'm checking their e-mail against the database, when they focus out of the e-mail input box. I only want to display a tooltip message if the e-mail has been taken and then make sure it dissapears if they provide a new unique e-mail address.</p> <p>Here is my code thus far: <strong>register.php (where the form is)</strong></p> <pre><code>&lt;div class="textboxfrm"&gt;&lt;span class="label"&gt;Email&lt;span style="color:#FF9000"&gt;* &lt;/span&gt; &lt;/span&gt;&lt;span class="left"&gt;&lt;/span&gt;&lt;span class="center"&gt;&lt;input class="required validate-email" id="email" name="email" type="text" style="width:230px;" maxlength="50" /&gt; &lt;/span&gt; &lt;div class="tooltip_email"&gt;&lt;/div&gt; &lt;/div&gt; </code></pre> <p><strong>register.js</strong> (loaded on document.ready)</p> <pre><code>jQuery("span.center").tooltip({ events: { span: 'dblclick, dblclick', input: 'blur, mouseout', }, effect: "slide", delay: 3000, onBeforeShow: function() { jQuery("#email").blur(function() { // when focus out email = jQuery('#email').attr('value'); if (email.length &gt; 1){ jQuery.ajax({ type: "GET", url: "checkusername.php", data: "email=" + email, success: function(data) { jQuery(".tooltip_email").html(data); } }); //end ajax call }//end if email &gt; 1 else { jQuery("span.center").tooltip.hide(); } //jQuery(".tooltip_email").hide(); });//end email blur //return false; } // end onBeforeShow function }); //end span.center tooltip </code></pre> <p>Finally, <strong>checkusername.php</strong> (where the database is accessed)</p> <pre><code>&lt;?php $email = $_GET['email']; // connection settings stored in file include("connectionParameters.php"); $connection = mysql_connect($host,$user,$pass) or die ("We're sorry, there seems to be an error. Please try again later."); mysql_select_db($database); $email = $_GET['email']; mysql_select_db("testdatabase", $con); $sql= sprintf("SELECT * FROM Users WHERE email='%s'", mysql_real_escape_string($email)); $result = mysql_query($sql); $row = mysql_fetch_array($result); $taken = $row['email']; if(mysql_num_rows($result) &gt; 0){ echo "&lt;p&gt;This email belongs to a registered user. Please provide a different email address, or visit &lt;a href='forgot_pass.php'&gt;this&lt;/a&gt; page to retrieve your password.&lt;/p&gt;"; } else if(mysql_num_rows($result) &lt; 1) { exit(); } mysql_close($con); ?&gt; </code></pre> <p>To make the question a little clearer, the checking of the email is working correctly and I'm seeing the message if an email is taken via the tooltip. However, I'm also seeing the tooltip with no message if I hover over "span.center" or if I change the email to a valid one or If the email is greater than 2 characters. My problem is that I don't want to see the tooltip box <strong>at all</strong> under any of those scenarios.</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.
    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