MyBB Community Forums

Full Version: Is it possible to embed registration form in header template?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I've done this before using qreg and editing the global qreg template to give a nice look.
It worked fine from the design point. From the admin point - I got a bot storm.
So I've successfully embedded it, but none of the validator messages are working. Is it possible to get it working? Is it because I'm using DIV instead of TD for the validator message IDs, maybe? Still, pretty happy it's working at all.
Stupid question, but have you got the JS required for the validator in the template?
I believe so. Here's the registration section of my header_welcomeblock_guest right now.

<form action="member.php" method="post" id="registration_form" name="registration_form"><input type="text" style="display: none;" value="" name="regcheck1" /><input type="text" style="display: none;" value="true" name="regcheck2" />

<span class="smalltext">Username</span><br />
<input type="text" class="textbox" placeholder="username" name="username" id="username" style="width: 300px; padding: 3px; font-size: 1.2em;" value="{$username}" />

<span class="smalltext">Password</span>
<h5>Password</h5><input type="text" class="textbox" name="password" id="password" placeholder="password" style="width: 300px; padding: 3px; float: left;" />

<span class="smalltext">Email</span>
<input type="text" class="textbox" name="email" id="email" style="width: 300px; padding: 3px;" maxlength="50" value="{$email}" />

<div id="email-status">&nbsp;</div>

<input type="hidden" name="step" value="registration" />
<input type="hidden" name="action" value="do_register" />
<input type="hidden" name="emailpmnotify" id="emailpmnotify" value="1" {$emailpmnotifycheck} />
<input type="hidden" name="receivepms" id="receivepms" value="1" {$receivepmscheck} />
<input type="hidden" name="pmnotice" id="pmnotice" value="1" {$pmnoticecheck} />
<input type="hidden" name="allownotices" id="allownotices" value="1" {$allownoticescheck} />

<input type="submit" class="button" style="font-size: 1.5em; margin-left: auto; margin-right: auto; width: 100%;" name="regsubmit" value="Let's do it" />
<input type="hidden" name="step" value="registration" />
<input type="hidden" name="action" value="do_register" />
</form>

<script type="text/javascript">
<!--
	regValidator = new FormValidator('registration_form');
	regValidator.register('username', 'notEmpty', {failure_message:'{$lang->js_validator_no_username}'});
    regValidator.register('email', 'regexp', {match_field:'email2', regexp:'^([a-zA-Z0-9_\\.\\+\\-])+\\@(([a-zA-Z0-9\\-])+\\.)+([a-zA-Z0-9]{2,4})+$', failure_message:'{$lang->js_validator_invalid_email}'});
	regValidator.register('email2', 'matches', {match_field:'email', status_field:'email_status', failure_message:'{$lang->js_validator_email_match}'});
{$validator_extra}
	regValidator.register('username', 'ajax', {url:'xmlhttp.php?action=username_availability', loading_message:'{$lang->js_validator_checking_username}'}); // needs to be last
// -->

</script>
Make sure this is in the <head>:

<script type="text/javascript" src="jscripts/validator.js"></script>
Thanks, that was part of the issue. Still having some problems, for example, the username box will highlight green even if the username already exists ... hm. I also changed the password to a single text-field the same way as e-mail using patches, but it seems like it doesn't validate at all now.
Not sure about the username, but the password won't validate because it'll still be looking for the two to match possibly.

If you want, I can take a look if the admin account I used before still exists?
It should still exist, yeah.
All sorted Smile Mark as solved?
Yes, thank you! Will share in Humanization Project later.
Pages: 1 2