4images Forum & Community
4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Topic started 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
"url_search" => $site_sess->url(ROOT_PATH."search.php"),
and add before:
"url_user_availability" => $site_sess->url(ROOT_PATH."user_availability.php", "&"),
Open header.html
After:
<link rel="stylesheet" href="{template_url}/style.css" />
Add:
<script src="jquery.js" type="text/javascript" language="javascript"></script>
Open register_form.html
Add to the top:
<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:
<input type="text" name="user_name" size="30" value="{user_name}" class="input" />
With:
<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:
<?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:
.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;
}
-
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.
-
Thank you :)
But how would you use $site_sess->url() in javascript to generate that url?
-
Gosh, how can I forgot something like that :roll: I'll post modification tomorrow. :wink:
Bye!
-
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
-
Also, <style> should be in header.html ;)
I have included <style> now directly in style.css file.
I hope this mod is valid now ;)
-
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 &
P.S.
$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:
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()
-
Thx, I fixed that!
-
[MOD] Ajax Username Checker
Can this feature be extended for image verification and check email format too?
Thanks for this lovely MOD!
-
For image verification defenitly not! But for email... maybe yes :roll:
-
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.
-
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!
-
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?
-
Die Idee finde ich ebenfalls sehr klasse!
-
gibt es hierzu evtl. schon was neues?
-
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
-
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
-
Funktioniert auch mit Version 1.7.1 :-)
-
Hi,
for disabling the submit button until the choosen username is free add this:
search for:
$("#username").blur(function()
add above:
$("#submitButton").attr("disabled", "true");
search for:
$(this).html('vergeben!').addClass('messageboxerror').fadeTo(900,1);
add below [Thanks to zhono for his fix]:
$("#submitButton").attr("disabled", "true");
search for:
$(this).html('Verfügbar').addClass('messageboxok').fadeTo(900,1);
add below:
$('#submitButton').removeAttr('disabled');
add this to the input submit tag:
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
-
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.
-
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
-
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.
-
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
-
And here is my final contribution to this great mod. Here's what it does:
- Check username to see if it exists
- Require username to be between X and X characters long
- Warns user if the username field is left blank
- Require the password to be between X and X characters long
- Warns user if the password field is left blank
- Make sure the email is someone@domain.com
- Make sure the email isn't already registed in your gallery.
- Warns user if the email field is left blank
- Submit button says "Disabled" and can't be clicked, until all items are entered correctly, then changes to "Register" and can be clicked.
After installing the original mod from Lucifix:
In page_header.php REPLACE:
"url_user_availability" => $site_sess->url(ROOT_PATH."user_availability.php", "&"),
With:
"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:
<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:
<input type="password" name="user_password" size="30" class="input" />
With:
<input type="password" name="user_password" size="30" class="input" id="userpassword" /><span id="msgboxpass" style="display:none"></span>
REPLACE:
<input type="text" name="user_email" size="30" class="input" value="{user_email}" />
With:
<input type="text" name="user_email" size="30" class="input" value="{user_email}" id="useremail" /><span id="msgboxemail" style="display:none"></span>
REPLACE:
<input type="submit" value="{lang_submit}" class="button" />
With:
<input type="submit" value="{lang_submit}" class="button" id="submitButton" />
In lang/english/main.php
Find
?>
Before ADD:
//----------------------------------------------------------
//-- 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:
"captcha_registration" => (bool)$captcha_enable_registration
Replace with:
"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:
<?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:
//username length
$MIN_LENGTH = 6;
$MAX_LENGTH = 20;
and
//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.
-
The above post has been updated to allow the Submit button to be disabled until all fields are entered correctly.
-
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:
{
//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
-
Sorry about that. Forgot to use code tags instead of php tags. Should be fixed now.
-
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
-
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.
-
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:
?>
Before ADD:
//----------------------------------------------------------
//-- 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:
"captcha_registration" => (bool)$captcha_enable_registration
Replace with:
"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:
<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.
-
(http://images.zwani.com/graphics/thanks_for_the_add/images/thanks-for-add15.jpg)
-
I used this plugin,but after a long time it's showing "Checking.."
How to solve this problem?
-
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??
-
...
..is this mod is error free??
yes
-
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...
============================================
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?
-
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]
-
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... :|
-
any solutions fot this? :roll:
-
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.
-
I am using Ajax user name check.but it's taking a long time.
-
Start with checking error console of your browser
-
We fixed the problem through PM. ;)