MyBB Community Forums

Full Version: Registration Form - Uncaught TypeError: $(...).validate is not a function
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Forumlink (still under construction): www.factcheckerz.com

Registration form validation script gives an error in Chrome. See attachment for the error.


Quote:jQuery.Deferred exception: $(...).validate is not a function TypeError: $(...).validate is not a function

    at HTMLDocument.<anonymous>



Template "Member_register" Code:
<script type="text/javascript">
$(document).ready(function() {
	$("#registration_form").validate({
		rules: {
			username: {
				required: true,
				minlength: {$mybb->settings['minnamelength']},
				maxlength: {$mybb->settings['maxnamelength']},
				remote: {
					url: "xmlhttp.php?action=username_availability",
					type: "post",
					dataType: "json",
					data:
					{
						my_post_key: my_post_key
					},
				},
			},
			email: {
				required: true,
				email: true,
			},
			email2: {
				required: true,
				email: true,
				equalTo: "#email"
			},
		},
		messages: {
			username: {
				minlength: "{$lang->js_validator_username_length}",
				maxlength: "{$lang->js_validator_username_length}",
			},
			email: "{$lang->js_validator_invalid_email}",
			email2: "{$lang->js_validator_email_match}",
		},
		errorPlacement: function(error, element) {
			if(element.is(':checkbox') || element.is(':radio'))
				error.insertAfter($('input[name="' + element.attr('name') + '"]').last().next('span'));
			else
				error.insertAfter(element);
		}
	});

	{$validator_extra}
});
</script>


I hope you can help me!
Solved it. And that is why you probably did not respond. It is a custom theme, Emerald that I customized.

What was wrong is that the script was not called in the template member_register.

<script type="text/javascript" src="{$mybb->asset_url}/jscripts/validate/jquery.validate.min.js?ver=1821"></script>


I placed this directly under the headerinclude and all was fine.
Like this.

<html>
<head>
<title>{$mybb->settings['bbname']} - {$lang->registration}</title>
{$headerinclude}
<script type="text/javascript" src="{$mybb->asset_url}/jscripts/validate/jquery.validate.min.js?ver=1821"></script>