4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Topic started by: Lucifix on January 13, 2009, 01:07:58 PM

Title: [MOD] Ajax Username Checker
Post by: Lucifix on January 13, 2009, 01:07:58 PM
Quote from original mod:
In this post,I’ll show you how to make a fancy username availability checking in ajax and php using jquery.When, you check the the username avaiability a fancy message box will show you the message with a little bit of animation. If you are looking for such kind of effect for checking username availability, then this might be right post for you.
http://roshanbh.com.np/2008/04/check-username-available-ajax-php-jquery.html

Download jquery.js file and upload it to root directory: (EDIT: I have attached file jquery.js to this message)
http://docs.jquery.com/Downloading_jQuery#Download_jQuery

Find in page_header.php
Code: [Select]
  "url_search" => $site_sess->url(ROOT_PATH."search.php"),
and add before:
Code: [Select]
  "url_user_availability" => $site_sess->url(ROOT_PATH."user_availability.php", "&"),
Open header.html
After:
Code: [Select]
<link rel="stylesheet" href="{template_url}/style.css" />
Add:
Code: [Select]
<script src="jquery.js" type="text/javascript" language="javascript"></script>

Open register_form.html
Add to the top:
Code: [Select]
<script language="javascript">
//<!---------------------------------+
//  Developed by Roshan Bhattarai
//  Visit http://roshanbh.com.np for this script and more.
//  This notice MUST stay intact for legal use
// --------------------------------->
$(document).ready(function()
{
$("#username").blur(function()
{
//remove all the class add the messagebox classes and start fading
$("#msgbox").removeClass().addClass('messagebox').text('Checking...').fadeIn("slow");
//check the username exists or not from ajax
$.post("{url_user_availability}",{ user_name:$(this).val() } ,function(data)
        {
  if(data=='no') //if username not avaiable
  {
  $("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
{
  //add message and change the class of the box and start fading
  $(this).html('This User name Already exists').addClass('messageboxerror').fadeTo(900,1);
});
          }
  else
  {
  $("#msgbox").fadeTo(200,0.1,function()  //start fading the messagebox
{
  //add message and change the class of the box and start fading
  $(this).html('Username available to register').addClass('messageboxok').fadeTo(900,1);
});
  }

        });
 
});
});
</script>

Replace:
Code: [Select]
<input type="text" name="user_name" size="30" value="{user_name}" class="input" />
With:
Code: [Select]
<input type="text" name="user_name" size="30" value="{user_name}" id="username" class="input" /><span id="msgbox" style="display:none"></span>
Create new PHP file, name it user_availability.php and upload it to root directory:

Code: [Select]
<?php
//  Developed by Roshan Bhattarai 
//  Visit http://roshanbh.com.np for this script and more.
//  This notice MUST stay intact for legal use

define('ROOT_PATH''./');
include(
ROOT_PATH.'global.php');
require(
ROOT_PATH.'includes/sessions.php');

if (isset(
$HTTP_POST_VARS['user_name'])) {
$user_name preg_replace("/[ ]{2,}/"" "un_htmlspecialchars(trim($HTTP_POST_VARS['user_name'])));

if ($user_name != "") {
  $sql "SELECT ".get_user_table_field("""user_name")."
  FROM "
.USERS_TABLE."
  WHERE "
.get_user_table_field("""user_name")." = '".strtolower($user_name)."'";
  if ($site_db->not_empty($sql)) {
//user name is not availble
echo "no";
  } else {
//user name is available
echo "yes";   
}
}
}
?>


Open style.css (folder: /templates/default) add to the end:
Code: [Select]
.messagebox{
position:absolute;
width:100px;
margin-left:10px;
padding:2px;
}
.messageboxok{
position:absolute;
width:auto;
margin-left:10px;
padding:2px;
font-weight:bold;
color:#008000;

}
.messageboxerror{
position:absolute;
width:auto;
margin-left:10px;
padding:2px;
font-weight:bold;
color:#CC0000;
}
Title: Re: [MOD] Ajax Username Checker
Post by: V@nо on January 13, 2009, 05:12:06 PM
Nice, just make sure you use $site_sess->url() to generate the url to user_availability.php, otherwise it might create a new session (and slow down the script) on each request.
Title: Re: [MOD] Ajax Username Checker
Post by: Lucifix on January 13, 2009, 06:18:21 PM
Thank you :)

But how would you use $site_sess->url() in javascript to generate that url?
Title: Re: [MOD] Ajax Username Checker
Post by: Lucifix on January 13, 2009, 07:31:56 PM
Gosh, how can I forgot something like that  :roll: I'll post modification tomorrow. :wink:

Bye!
Title: Re: [MOD] Ajax Username Checker
Post by: V@no on January 14, 2009, 03:15:48 AM
Also, <style> should be in header.html ;)
By the way, coincidentally, just a few days ago I had question (http://forums.devshed.com/html-programming-1/is-style-must-be-inside-head-or-can-also-be-583204.html) regarding <style> myself
Title: Re: [MOD] Ajax Username Checker
Post by: Lucifix on January 14, 2009, 07:58:06 AM
Also, <style> should be in header.html ;)

I have included <style> now directly in style.css file.

I hope this mod is valid now ;)
Title: Re: [MOD] Ajax Username Checker
Post by: V@no on January 14, 2009, 08:56:13 AM
Since the URL is executed directly by JS, I think you should use $site_sess->url(ROOT_PATH."user_availability.php", "&")
otherwise you'll get url with &amp;

P.S.

Code: [Select]
  $user_name = (isset($HTTP_POST_VARS['user_name'])) ? un_htmlspecialchars(trim($HTTP_POST_VARS['user_name'])) : "";
  $user_name = ereg_replace("( ){2,}", " ", $user_name);

  if (isset($HTTP_POST_VARS['user_name'])) {

can be optimized with:
Code: [Select]
  if (isset($HTTP_POST_VARS['user_name'])) {
  $user_name = preg_replace("/[ ]{2,}/", " ", un_htmlspecialchars(trim($HTTP_POST_VARS['user_name'])));

I don't know why ereg_replace() exists, in my benchmark it's over 50% slower then preg_replace()
Title: Re: [MOD] Ajax Username Checker
Post by: Lucifix on January 14, 2009, 09:05:56 AM
Thx, I fixed that!
Title: Re: [MOD] Ajax Username Checker
Post by: Eagle Eye on March 19, 2009, 11:31:53 AM
[MOD] Ajax Username Checker

Can this feature be extended for image verification and check email format too?

Thanks for this lovely MOD!
Title: Re: [MOD] Ajax Username Checker
Post by: Lucifix on March 19, 2009, 11:36:23 AM
For image verification  defenitly not! But for email... maybe yes :roll:
Title: Re: [MOD] Ajax Username Checker
Post by: neverkas on May 25, 2009, 03:38:04 PM
a mi no me funciona!  8O

Me dice que esta disponible tal usuario, pero en realidad ya está registrado...

Qué sucede? Por qué el error?
Hice paso por paso tal cual.
Title: Re: [MOD] Ajax Username Checker
Post by: Sunny C. on May 28, 2009, 12:04:18 AM
Kann das jemand vielleicht mal auffrischen?
In der 1.7.7 klappt das irgendwie nicht, obwohl ich mir nicht vorstellen kann warum.
Liegt es vielleicht an dieser PHP Datei, die man erstellen muss?

Ich würde gerne das Script verwenden:
http://www.pa-s.de/php/codeschnipsel-AJAX-Username-Check-52.php

Aber ich weis nicht wie man eine Datenbankanfrage erstellt!
Title: Re: [MOD] Ajax Username Checker
Post by: bergblume on May 28, 2009, 08:59:31 AM
kann man diesen mod mittlerweile auch als image name checker modifizieren und verwenden - sprich, dass wenn ein user z.B. "schönes Bild" als Bildname eingibt - dies automatisch gegengeprüft wird?
Title: Re: [MOD] Ajax Username Checker
Post by: Sunny C. on May 28, 2009, 02:52:58 PM
Die Idee finde ich ebenfalls sehr klasse!
Title: Re: [MOD] Ajax Username Checker
Post by: bergblume on September 07, 2009, 05:23:25 PM
gibt es hierzu evtl. schon was neues?
Title: Re: [MOD] Ajax Username Checker
Post by: whonderbah on November 10, 2009, 01:34:54 PM
Hi,

I've a problem, the is working very well but i realized that the verification was changing when you click the image after i made this mod it didn't change when you click it. I think the problem is about java..

Can you help me?

Thank you
Title: Re: [MOD] Ajax Username Checker
Post by: Hoelsch on November 12, 2009, 01:45:49 PM
Hi,

very nice Mod! It's working fine for me!

Is it possible to use it for Password and E-Mail verification, too? And if it's possible what do I have to do?

Greetz

Hoelsch
Title: Re: [MOD] Ajax Username Checker
Post by: www.katzen.ag on July 31, 2010, 12:15:04 PM
Funktioniert auch mit Version 1.7.1 :-)
Title: Re: [MOD] Ajax Username Checker
Post by: x23piracy on November 26, 2010, 04:27:41 AM
Hi,

for disabling the submit button until the choosen username is free add this:

search for:
Code: [Select]
$("#username").blur(function()
add above:
Code: [Select]
$("#submitButton").attr("disabled", "true");
search for:
Code: [Select]
$(this).html('vergeben!').addClass('messageboxerror').fadeTo(900,1);
add below [Thanks to zhono for his fix]:
Code: [Select]
$("#submitButton").attr("disabled", "true");
search for:
Code: [Select]
 $(this).html('Verfügbar').addClass('messageboxok').fadeTo(900,1);
add below:
Code: [Select]
 $('#submitButton').removeAttr('disabled');
add this to the input submit tag:
Code: [Select]
id="submitButton"

i would like to know more about jquery and the syntax... so the hole form can be blocked
until it's filled out completely... i don't know, who knows?


Greetz X23
Title: Re: [MOD] Ajax Username Checker
Post by: zhono on December 02, 2010, 04:51:34 AM
Excellent mod. One thing though. If you click away from the username box, but leave it blank, it will say that the username is available. Any way to get it to instead say "Please enter a username"?

*EDIT*

Figured it out myself.

In user_availability.php

Replace:
if (isset($HTTP_POST_VARS['user_name'])) {

With:
if (isset($HTTP_POST_VARS['user_name']) && !empty($HTTP_POST_VARS['user_name'])) {

Replace:
}
?>

With:
} else {
echo "blank";
}
?>

In register_form.html

Replace:
  if(data=='no') //if username not avaiable

With:
      if(data=='blank') //if username not entered
  {
  $("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
{
  //add message and change the class of the box and start fading
  $(this).html('Please enter a username').addClass('messageboxerror').fadeTo(900,1);
});
          }
  else if(data=='no') //if username not avaiable

Now if you don't enter a username, it'll tell you so.
Title: Re: [MOD] Ajax Username Checker
Post by: x23piracy on December 02, 2010, 05:32:49 AM
Excellent mod. One thing though. If you click away from the username box, but leave it blank, it will say that the username is available. Any way to get it to instead say "Please enter a username"?

Hi,

first of all i don't have the solution yet but it would be nice if the user enters the
username field that he cannot leave it until he entered a username with a length of X

Go go Lucifix go luci go  :thumbup:


Greetz X23
Title: Re: [MOD] Ajax Username Checker
Post by: zhono on December 02, 2010, 05:37:26 AM
Good idea. Maybe I can do that one myself too. Also, that last mod that you posted, if a user enters an available name, it will activate the submit button. Then he can go back and change to a name that is taken, and the submit button will still work.

So just do this.

*EDIT* Modified the code one more time, check my next post.
Title: Re: [MOD] Ajax Username Checker
Post by: x23piracy on December 02, 2010, 07:17:55 AM
Hi,

that last mod that you posted...
So just do this.

thank you for the fix, i have updated my post with the change and a credit.

And require a username to be between X and X characters long, do this:

Thank you again i test this later.  :thumbup:


Greetz X23
Title: Re: [MOD] Ajax Username Checker
Post by: zhono on December 02, 2010, 12:32:47 PM
And here is my final contribution to this great mod. Here's what it does:



After installing the original mod from Lucifix:

In page_header.php REPLACE:
Code: [Select]
 "url_user_availability" => $site_sess->url(ROOT_PATH."user_availability.php", "&"),
With:
Code: [Select]
 "url_user_availability" => $site_sess->url(ROOT_PATH."user_availability.php?check=username", "&"),
  "url_user_email" => $site_sess->url(ROOT_PATH."user_availability.php?check=email", "&"),
  "url_user_password" => $site_sess->url(ROOT_PATH."user_availability.php?check=password", "&"),

In register_form.html

REPLACE the original javascript at the top with this:
Code: [Select]
<script language="javascript">
//<!---------------------------------+
//  Developed by Roshan Bhattarai
//  Visit http://roshanbh.com.np for this script and more.
//  This notice MUST stay intact for legal use
//  Extensive additions by Zhono
// --------------------------------->

$(document).ready(function()
{
var userOk = 0;
var passOk = 0;
var emailOk = 0;
$("#submitButton").attr("value", "Disabled");
$("#submitButton").attr("disabled", "true");
$("#username").blur(function()
{
//remove all the class add the messagebox classes and start fading
$("#msgbox").removeClass().addClass('messagebox').text('Checking...').fadeIn("slow");
//check the username exists or not from ajax
$.post("{url_user_availability}",{ user_name:$(this).val() } ,function(data)
        {
     if(data=='userblank') //if username not entered
 {
  $("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
{
 //add message and change the class of the box and start fading
 $(this).html('{lang_ajax_username_empty}').addClass('messageboxerror').fadeTo(900,1);
 
});
userOk = 0;
          }
 else if(data=='userlength') //if username is less than 6 or more than 20 characters
 {
  $("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
{
 //add message and change the class of the box and start fading
 $(this).html('{lang_ajax_username_length}').addClass('messageboxerror').fadeTo(900,1);
 
});
userOk = 0;
          }
 else if(data=='userno') //if username not avaiable
 {
  $("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
{
 //add message and change the class of the box and start fading
 $(this).html('{lang_ajax_username_taken}').addClass('messageboxerror').fadeTo(900,1);
 
});
userOk = 0;
          }
 else
 {
  $("#msgbox").fadeTo(200,0.1,function()  //start fading the messagebox
{
 //add message and change the class of the box and start fading
 $(this).html('{lang_ajax_username_good}').addClass('messageboxok').fadeTo(900,1);
 
});
userOk = 1;
 if (userOk==1 && passOk==1 && emailOk==1) {
 $("#submitButton").attr("value", "Register");
 $('#submitButton').removeAttr('disabled');
 } else {
$("#submitButton").attr("disabled", "true");
$("#submitButton").attr("value", "Disabled");
}
 }

        });
});
$("#userpassword").blur(function()
{
//remove all the class add the messagebox classes and start fading
$("#msgboxpass").removeClass().addClass('messagebox').text('Checking...').fadeIn("slow");
//check the username exists or not from ajax
$.post("{url_user_password}",{ user_password:$(this).val() } ,function(data)
        {
     if(data=='passblank') //if username not entered
 {
  $("#msgboxpass").fadeTo(200,0.1,function() //start fading the messagebox
{
 //add message and change the class of the box and start fading
 $(this).html('{lang_ajax_password_empty}').addClass('messageboxerror').fadeTo(900,1);
 
});
passOk = 0;
          }
 else if(data=='passlength') //if username is less than 6 or more than 20 characters
 {
  $("#msgboxpass").fadeTo(200,0.1,function() //start fading the messagebox
{
 //add message and change the class of the box and start fading
 $(this).html('{lang_ajax_password_length}').addClass('messageboxerror').fadeTo(900,1);
 
});
passOk = 0;
          }
 else
 {
  $("#msgboxpass").fadeTo(200,0.1,function()  //start fading the messagebox
{
 //add message and change the class of the box and start fading
 $(this).html('{lang_ajax_password_good}').addClass('messageboxok').fadeTo(900,1);
 
});
passOk = 1;
 if (userOk==1 && passOk==1 && emailOk==1) {
 $("#submitButton").attr("value", "Register");
 $('#submitButton').removeAttr('disabled');
 } else {
$("#submitButton").attr("disabled", "true");
$("#submitButton").attr("value", "Disabled");
}
 }

        });
});
$("#useremail").blur(function()
{
//remove all the class add the messagebox classes and start fading
$("#msgboxemail").removeClass().addClass('messagebox').text('Checking...').fadeIn("slow");
//check the username exists or not from ajax
$.post("{url_user_email}",{ user_email:$(this).val() } ,function(data)
        {
     if(data=='emailblank') //if username not entered
 {
  $("#msgboxemail").fadeTo(200,0.1,function() //start fading the messagebox
{
 //add message and change the class of the box and start fading
 $(this).html('{lang_ajax_email_empty}').addClass('messageboxerror').fadeTo(900,1);
 
});
emailOk = 0;
          }
 else if(data=='emailinvalid') //if username is less than 6 or more than 20 characters
 {
  $("#msgboxemail").fadeTo(200,0.1,function() //start fading the messagebox
{
 //add message and change the class of the box and start fading
 $(this).html('{lang_ajax_email_invalid}').addClass('messageboxerror').fadeTo(900,1);
 
});
emailOk = 0;
          }
 else if(data=='emailno') //if username not avaiable
 {
  $("#msgboxemail").fadeTo(200,0.1,function() //start fading the messagebox
{
 //add message and change the class of the box and start fading
 $(this).html('{lang_ajax_email_taken}').addClass('messageboxerror').fadeTo(900,1);
 
});
emailOk = 0;
          }
 else
 {
  $("#msgboxemail").fadeTo(200,0.1,function()  //start fading the messagebox
{
 //add message and change the class of the box and start fading
 $(this).html('{lang_ajax_email_good}').addClass('messageboxok').fadeTo(900,1);
 
});
emailOk = 1;
 if (userOk==1 && passOk==1 && emailOk==1) {
 $("#submitButton").attr("value", "Register");
 $('#submitButton').removeAttr('disabled');
 } else {
$("#submitButton").attr("disabled", "true");
$("#submitButton").attr("value", "Disabled");
}
 }

        });
 
});
});
</script>

REPLACE:
Code: [Select]
<input type="password" name="user_password" size="30" class="input" />
With:
Code: [Select]
<input type="password" name="user_password" size="30" class="input"  id="userpassword" /><span id="msgboxpass" style="display:none"></span>
REPLACE:
Code: [Select]
<input type="text" name="user_email" size="30" class="input" value="{user_email}" />
With:
Code: [Select]
<input type="text" name="user_email" size="30" class="input" value="{user_email}" id="useremail" /><span id="msgboxemail" style="display:none"></span>
REPLACE:
Code: [Select]
<input type="submit" value="{lang_submit}" class="button" />
With:
Code: [Select]
<input type="submit" value="{lang_submit}" class="button" id="submitButton" />
In lang/english/main.php

Find
Code: [Select]
?>
Before ADD:
Code: [Select]
//----------------------------------------------------------
//-- Mod Ajax Registration Checker --
//----------------------------------------------------------
$lang['ajax_username_empty'] = "Please enter a username";
$lang['ajax_username_length'] = "Username must be between 6 and 20 characters long";
$lang['ajax_username_taken'] = "This User name already exists";
$lang['ajax_username_good'] = "Username available to register";
$lang['ajax_password_empty'] = "Please enter a password";
$lang['ajax_password_length'] = "Password must be between 6 and 20 characters long";
$lang['ajax_password_good'] = "Password is good";
$lang['ajax_email_empty'] = "Please enter an email address";
$lang['ajax_email_invalid'] = "This email address is invalid!";
$lang['ajax_email_taken'] = "This email address is already registered";
$lang['ajax_email_good'] = "Email address is good to go";

In register.php

Find:
Code: [Select]
      "captcha_registration" => (bool)$captcha_enable_registration
Replace with:
Code: [Select]
     "captcha_registration" => (bool)$captcha_enable_registration,
      "lang_ajax_username_empty" => $lang['ajax_username_empty'],
      "lang_ajax_username_length" => $lang['ajax_username_length'],
      "lang_ajax_username_taken" => $lang['ajax_username_taken'],
      "lang_ajax_username_good" => $lang['ajax_username_good'],
      "lang_ajax_password_empty" => $lang['ajax_password_empty'],
      "lang_ajax_password_length" => $lang['ajax_password_length'],
      "lang_ajax_password_good" => $lang['ajax_password_good'],
      "lang_ajax_email_empty" => $lang['ajax_email_empty'],
      "lang_ajax_email_invalid" => $lang['ajax_email_invalid'],
      "lang_ajax_email_taken" => $lang['ajax_email_taken'],
      "lang_ajax_email_good" => $lang['ajax_email_good']

And finally, REPLACE you entire user_availability.php with this:
Code: [Select]
<?php
//  Developed by Roshan Bhattarai 
//  Visit http://roshanbh.com.np for this script and more.
//  This notice MUST stay intact for legal use
//  Extensive additions by Zhono

define('ROOT_PATH''./');
include(
ROOT_PATH.'global.php');
require(
ROOT_PATH.'includes/sessions.php');

if (
$_GET['check'] == "username") {
if (isset(
$HTTP_POST_VARS['user_name']) && !empty($HTTP_POST_VARS['user_name'])) {
$user_name preg_replace("/[ ]{2,}/"" "un_htmlspecialchars(trim($HTTP_POST_VARS['user_name'])));
//username length
$MIN_LENGTH 6;
$MAX_LENGTH 20;
if ((strlen($user_name) < $MIN_LENGTH) || (strlen($user_name) > $MAX_LENGTH)) {
    
echo "userlength";
  
} else {

if ($user_name != "") {
  $sql "SELECT ".get_user_table_field("""user_name")."
  FROM "
.USERS_TABLE."
  WHERE "
.get_user_table_field("""user_name")." = '".strtolower($user_name)."'";
  if ($site_db->not_empty($sql)) {
//user name is not availble
echo "userno";
  } else {
//user name is available
echo "useryes";   
}
}
  }
} else {
echo "userblank";
}
}

if (
$_GET['check'] == "password") {
if (isset(
$HTTP_POST_VARS['user_password']) && !empty($HTTP_POST_VARS['user_password'])) {
$user_password preg_replace("/[ ]{2,}/"" "un_htmlspecialchars(trim($HTTP_POST_VARS['user_password'])));
//password length
$MIN_LENGTH 6;
$MAX_LENGTH 20;
if ((strlen($user_password) < $MIN_LENGTH) || (strlen($user_password) > $MAX_LENGTH)) {
    
echo "passlength";
  
} else {
   echo "passyes";
  }
} else {
echo "passblank";
}
}

if (
$_GET['check'] == "email") {
if (isset(
$HTTP_POST_VARS['user_email']) && !empty($HTTP_POST_VARS['user_email'])) {

$user_email $HTTP_POST_VARS['user_email'];

if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$"$user_email)){
echo "emailinvalid";
} else {

if ($user_email != "") {
  $sql "SELECT ".get_user_table_field("""user_email")."
  FROM "
.USERS_TABLE."
  WHERE "
.get_user_table_field("""user_email")." = '".strtolower($user_email)."'";
  if ($site_db->not_empty($sql)) {
//user name is not availble
echo "emailno";
  } else {
//user name is available
echo "emailyes";   
}
}
  }
} else {
echo "emailblank";
}
}
?>

That should do it. To change the allowed length of the username and password:

In user_availability.php FIND:
Code: [Select]
//username length
$MIN_LENGTH = 6;
$MAX_LENGTH = 20;
and
Code: [Select]
//password length
$MIN_LENGTH = 6;
$MAX_LENGTH = 20;

Change 6 to your desired minimum number of characters, and change 20 the the max allowed characters.

Done!

*EDIT* Oh, and Lucifix, feel free to update your original post with this new version if you want. That way, people won't have to install it, and then update it to this.
Title: Re: [MOD] Ajax Username Checker
Post by: zhono on December 06, 2010, 02:36:55 PM
The above post has been updated to allow the Submit button to be disabled until all fields are entered correctly.
Title: Re: [MOD] Ajax Username Checker
Post by: x23piracy on December 06, 2010, 03:22:55 PM
The above post has been updated to allow the Submit button to be disabled until all fields are entered correctly.

Hi,

please paste the code source clean so they can be copy and pasted, there are much breaks
after each line if you paste that... i found that different times in other MOD's.

It's a pain to remove those unneeded line breaks.

For example:

Code: [Select]
{



  //add message and change the class of the box and start fading



  $(this).html('This email address is already registered').addClass('messageboxerror').fadeTo(900,1);



  



});



emailOk = 0;


Greetz X23
Title: Re: [MOD] Ajax Username Checker
Post by: zhono on December 06, 2010, 04:10:21 PM
Sorry about that. Forgot to use code tags instead of php tags. Should be fixed now.
Title: Re: [MOD] Ajax Username Checker
Post by: x23piracy on December 06, 2010, 04:55:56 PM
Sorry about that. Forgot to use code tags instead of php tags. Should be fixed now.

Hi,

thx the code seems to work good :) just tested it a few times worked...
What about language tags?


Greetz X23
Title: Re: [MOD] Ajax Username Checker
Post by: zhono on December 06, 2010, 05:12:26 PM
I tried using language tags already, and they wouldn't work inside the javascript. Maybe I overlooked something. I have some personal stuff going on right now, so I can't work on it at the moment. If someone else wants to have a look at that, obviously they are free to. If I can sort out my personal stuff, I'll try again, but it's not likely to be soon.
Title: Re: [MOD] Ajax Username Checker
Post by: zhono on December 09, 2010, 03:16:33 AM
I updated my code above to include language tags. If you are already using the code, here are the changes.

In lang/english/main.php

Find:
Code: [Select]
?>
Before ADD:
Code: [Select]
//----------------------------------------------------------
//-- Mod Ajax Registration Checker --
//----------------------------------------------------------
$lang['ajax_username_empty'] = "Please enter a username";
$lang['ajax_username_length'] = "Username must be between 6 and 20 characters long";
$lang['ajax_username_taken'] = "This User name already exists";
$lang['ajax_username_good'] = "Username available to register";
$lang['ajax_password_empty'] = "Please enter a password";
$lang['ajax_password_length'] = "Password must be between 6 and 20 characters long";
$lang['ajax_password_good'] = "Password is good";
$lang['ajax_email_empty'] = "Please enter an email address";
$lang['ajax_email_invalid'] = "This email address is invalid!";
$lang['ajax_email_taken'] = "This email address is already registered";
$lang['ajax_email_good'] = "Email address is good to go";

In register.php

Find:
Code: [Select]
     "captcha_registration" => (bool)$captcha_enable_registration
Replace with:
Code: [Select]
     "captcha_registration" => (bool)$captcha_enable_registration,
      "lang_ajax_username_empty" => $lang['ajax_username_empty'],
      "lang_ajax_username_length" => $lang['ajax_username_length'],
      "lang_ajax_username_taken" => $lang['ajax_username_taken'],
      "lang_ajax_username_good" => $lang['ajax_username_good'],
      "lang_ajax_password_empty" => $lang['ajax_password_empty'],
      "lang_ajax_password_length" => $lang['ajax_password_length'],
      "lang_ajax_password_good" => $lang['ajax_password_good'],
      "lang_ajax_email_empty" => $lang['ajax_email_empty'],
      "lang_ajax_email_invalid" => $lang['ajax_email_invalid'],
      "lang_ajax_email_taken" => $lang['ajax_email_taken'],
      "lang_ajax_email_good" => $lang['ajax_email_good']

And then once again replace the whole javascript in register_form.html with this:
Code: [Select]
<script language="javascript">
//<!---------------------------------+
//  Developed by Roshan Bhattarai
//  Visit http://roshanbh.com.np for this script and more.
//  This notice MUST stay intact for legal use
//  Extensive additions by Zhono
// --------------------------------->

$(document).ready(function()
{
var userOk = 0;
var passOk = 0;
var emailOk = 0;
$("#submitButton").attr("value", "Disabled");
$("#submitButton").attr("disabled", "true");
$("#username").blur(function()
{
//remove all the class add the messagebox classes and start fading
$("#msgbox").removeClass().addClass('messagebox').text('Checking...').fadeIn("slow");
//check the username exists or not from ajax
$.post("{url_user_availability}",{ user_name:$(this).val() } ,function(data)
        {
     if(data=='userblank') //if username not entered
 {
  $("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
{
 //add message and change the class of the box and start fading
 $(this).html('{lang_ajax_username_empty}').addClass('messageboxerror').fadeTo(900,1);
 
});
userOk = 0;
          }
 else if(data=='userlength') //if username is less than 6 or more than 20 characters
 {
  $("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
{
 //add message and change the class of the box and start fading
 $(this).html('{lang_ajax_username_length}').addClass('messageboxerror').fadeTo(900,1);
 
});
userOk = 0;
          }
 else if(data=='userno') //if username not avaiable
 {
  $("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
{
 //add message and change the class of the box and start fading
 $(this).html('{lang_ajax_username_taken}').addClass('messageboxerror').fadeTo(900,1);
 
});
userOk = 0;
          }
 else
 {
  $("#msgbox").fadeTo(200,0.1,function()  //start fading the messagebox
{
 //add message and change the class of the box and start fading
 $(this).html('{lang_ajax_username_good}').addClass('messageboxok').fadeTo(900,1);
 
});
userOk = 1;
 if (userOk==1 && passOk==1 && emailOk==1) {
 $("#submitButton").attr("value", "Register");
 $('#submitButton').removeAttr('disabled');
 } else {
$("#submitButton").attr("disabled", "true");
$("#submitButton").attr("value", "Disabled");
}
 }

        });
});
$("#userpassword").blur(function()
{
//remove all the class add the messagebox classes and start fading
$("#msgboxpass").removeClass().addClass('messagebox').text('Checking...').fadeIn("slow");
//check the username exists or not from ajax
$.post("{url_user_password}",{ user_password:$(this).val() } ,function(data)
        {
     if(data=='passblank') //if username not entered
 {
  $("#msgboxpass").fadeTo(200,0.1,function() //start fading the messagebox
{
 //add message and change the class of the box and start fading
 $(this).html('{lang_ajax_password_empty}').addClass('messageboxerror').fadeTo(900,1);
 
});
passOk = 0;
          }
 else if(data=='passlength') //if username is less than 6 or more than 20 characters
 {
  $("#msgboxpass").fadeTo(200,0.1,function() //start fading the messagebox
{
 //add message and change the class of the box and start fading
 $(this).html('{lang_ajax_password_length}').addClass('messageboxerror').fadeTo(900,1);
 
});
passOk = 0;
          }
 else
 {
  $("#msgboxpass").fadeTo(200,0.1,function()  //start fading the messagebox
{
 //add message and change the class of the box and start fading
 $(this).html('{lang_ajax_password_good}').addClass('messageboxok').fadeTo(900,1);
 
});
passOk = 1;
 if (userOk==1 && passOk==1 && emailOk==1) {
 $("#submitButton").attr("value", "Register");
 $('#submitButton').removeAttr('disabled');
 } else {
$("#submitButton").attr("disabled", "true");
$("#submitButton").attr("value", "Disabled");
}
 }

        });
});
$("#useremail").blur(function()
{
//remove all the class add the messagebox classes and start fading
$("#msgboxemail").removeClass().addClass('messagebox').text('Checking...').fadeIn("slow");
//check the username exists or not from ajax
$.post("{url_user_email}",{ user_email:$(this).val() } ,function(data)
        {
     if(data=='emailblank') //if username not entered
 {
  $("#msgboxemail").fadeTo(200,0.1,function() //start fading the messagebox
{
 //add message and change the class of the box and start fading
 $(this).html('{lang_ajax_email_empty}').addClass('messageboxerror').fadeTo(900,1);
 
});
emailOk = 0;
          }
 else if(data=='emailinvalid') //if username is less than 6 or more than 20 characters
 {
  $("#msgboxemail").fadeTo(200,0.1,function() //start fading the messagebox
{
 //add message and change the class of the box and start fading
 $(this).html('{lang_ajax_email_invalid}').addClass('messageboxerror').fadeTo(900,1);
 
});
emailOk = 0;
          }
 else if(data=='emailno') //if username not avaiable
 {
  $("#msgboxemail").fadeTo(200,0.1,function() //start fading the messagebox
{
 //add message and change the class of the box and start fading
 $(this).html('{lang_ajax_email_taken}').addClass('messageboxerror').fadeTo(900,1);
 
});
emailOk = 0;
          }
 else
 {
  $("#msgboxemail").fadeTo(200,0.1,function()  //start fading the messagebox
{
 //add message and change the class of the box and start fading
 $(this).html('{lang_ajax_email_good}').addClass('messageboxok').fadeTo(900,1);
 
});
emailOk = 1;
 if (userOk==1 && passOk==1 && emailOk==1) {
 $("#submitButton").attr("value", "Register");
 $('#submitButton').removeAttr('disabled');
 } else {
$("#submitButton").attr("disabled", "true");
$("#submitButton").attr("value", "Disabled");
}
 }

        });
 
});
});
</script>


And then just edit the language tags to suit your needs, obviously.
Title: Re: [MOD] Ajax Username Checker
Post by: x23piracy on December 09, 2010, 07:16:11 AM
(http://images.zwani.com/graphics/thanks_for_the_add/images/thanks-for-add15.jpg)
Title: Re: [MOD] Ajax Username Checker
Post by: raghunadhreddys on December 09, 2010, 12:05:48 PM
I used this plugin,but after a long time it's showing "Checking.."

How to solve this problem?
Title: Re: [MOD] Ajax Username Checker
Post by: haider512 on December 28, 2010, 12:45:21 AM
I used this plugin,but after a long time it's showing "Checking.."

How to solve this problem?

is this solved or this mode still have issues??

its seems to b a pretty great mod..if it is working fine....can any one confirm..is this mod is error free??
Title: Re: [MOD] Ajax Username Checker
Post by: Rembrandt on December 28, 2010, 05:08:59 AM
...
..is this mod is error free??
yes
Title: Re: [MOD] Ajax Username Checker
Post by: haider512 on December 28, 2010, 09:44:11 PM
Many Thanks for this Mod.. very nice mod indeed..

but im having little problem..as i have set the template in html..so it is not fitting in it..

can any one tell me that what code should i do in it that it automoatically makes its place below the text feild??

i mean when the user write username..it checks it..and the text comes next to it..

but is it possible that when the text comes then automatically adjust its place..

see the screenshot please...


============================================

Quote
Hi,

I've a problem, the is working very well but i realized that the verification was changing when you click the image after i made this mod it didn't change when you click it. I think the problem is about java..

Can you help me?

Thank you

Mine too..the image reload dosent work when clicked..
i mean it dont refresh..how to fix it?
Title: Re: [MOD] Ajax Username Checker
Post by: haider512 on December 30, 2010, 03:12:16 AM
And here is my final contribution to this great mod.


very nice zohoo...

can you also guide me that how is it possible that i can do this javascripting thing with my new feild i created in registration page with name of cusit..

this is the my site..

cusitlibrary.com/register.php

The New Field name is Cusit ID?

i want also javascript apply to it..that if some one click on alphabet..then it displays only numeric.. well i already restricted it..that chracters cant b typed but it displays message that no charachters. put University ID etc..

Also if some one put more numbers then 4 then it should also give message..i already done maxlength to 4 but when some one types 5th digit it should display message...


please make it possible..

Kind Regards
Haider

[EDIT by V@no]
please stop quote entire posts, leave only the relevant highlights in the quote

P.S. it is also a good idea copy/paste names to avoid embarrassing misspells (whis)
[/EDIT]
Title: Re: [MOD] Ajax Username Checker
Post by: k1lljoy on March 04, 2011, 09:58:20 PM
Hi!
The MOD works fine, exept for one thing - just noticed, that it checks right only usernames with latin characters and numerals, the usernames in cyrillics are always available for registration, notwithstanfing the fact, they are already in use in fact...  :|
Title: Re: [MOD] Ajax Username Checker
Post by: k1lljoy on March 07, 2011, 12:46:21 PM
any solutions fot this?  :roll:
Title: Re: [MOD] Ajax Username Checker
Post by: syamexpress on March 31, 2012, 03:13:45 PM
hi friends,i installed ajax user name check mod 4 days ago.it's not working.

It's displaying the message "Checking..." i tried it long time after 4 hours it's still checking.

please solve my problem.
Title: Ajax Username check takes a long time
Post by: syamexpress on April 03, 2012, 05:36:54 PM
I am using Ajax user name check.but it's taking a long time.
Title: Re: [MOD] Ajax Username Checker
Post by: V@no on April 04, 2012, 02:30:18 PM
Start with checking error console of your browser
Title: Re: [MOD] Ajax Username Checker
Post by: Lucifix on April 04, 2012, 02:32:03 PM
We fixed the problem through PM. ;)