Topic: Hard Cover Mod: Ajax username and email check
This is my answer for the AtPetat's feature request I've just made and I thank him for kind of moving me to do it. Also thanks to vldPersonals reusable functions.
1. Open your lang.lib.account_register.php and add these lang strings:
"username_ok" =>
"Username ok",
"email_ok" =>
"Email ok",2. Open your /includes/js/misc.js and add at the bottom of file this code:
// username check
function check_item(item_type, item_id, emptyfield)
{
var item_value = $('#'+item_id).val();
$.post(virpath+'index.php?m=ajaxcheck', {'item_type':item_type,'item_value':item_value},
function(response) {
var response = response.split("|");
if ( response.length == 2 )
{
if ( response[0] == 'ok' && response[1] )
{
document.getElementById(item_id+'_check').style.color = '#5B5BFF';
$('#'+item_id+'_check').html(response[1]);
return true;
}
else if ( response[0] == 'notok' && response[1] )
{
document.getElementById(item_id+'_check').style.color = '#FF0000';
$('#'+item_id+'_check').html(response[1]);
return true;
}
}
}
);
}3. Download http://www.zhunussov.com/uploads/lib.ajaxcheck.zip
Unzip and place in your /includes/lib/ directory.
4. Open your account_register.tpl and make two replacements (softgreen template example):
<dd><input name="username" type="text" class="text" id="field_username" value="{registration_username}" size="32" maxlength="16" /></dd><dd><input name="username" type="text" class="text" id="field_username" onBlur="check_item('username','field_username');" value="{registration_username}" size="32" maxlength="16" /> <span id="field_username_check"> </span></dd>and
<dd><input type="text" class="text" id="field_email" name="email" value="{registration_email}" size="32" maxlength="64" /></dd>to:
<dd><input type="text" class="text" id="field_email" name="email" onBlur="check_item('email','field_email');" value="{registration_email}" size="32" maxlength="64" /> <span id="field_email_check"> </span></dd>Now you have on-fly username and (first) email address check with the all existing validation rules etc.
Best regards,
Radioactive
www.vldCrowd.com/radioact - my profile at vldCrowd