Form Validation via added jQuery Code

Hi - I’m trying to validate some fields in a registration form I designed with WFD. I added the code below in the Custom Code - Head section and see it shows up okay when I export the site. For whatever reason I can’t seem to get it to validate email addresses of to verify that the 2 passwords entered match. It seems my jQuery code to validate never runs. I made sure the added code uses the same field ID’s as the ones WFD generates. Here’s the code, any help is greatly appreciated…

<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.12.0/jquery.validate.min.js" type="text/javascript"></script>
<script>
$.validator.setDefaults(
{
	submitHandler: function() 
	{
		alert("submitted!");
	}
});

$().ready(function() {
	// validate signup form on keyup and submit
	$("#email-form").validate({
		rules: 
		{
			First-Name-3: "required",
			Last-Name: "required",
			{
				required: true,
				minlength: 2
			},
			Email-Address: 
			{
				required: true,
				email: true
			},
			Company-Name: "required",
			{
				required: true,
				minlength: 2
			},
			Password-2: 
			{
				required: true,
				minlength: 8
			},
			Verify-Password: 
			{
				required: true,
				minlength: 8,
				equalTo: "#Verify-Password"
			},
			Terms-Of-Service: "required",
			Privacy-Policy-2: "required",
			Occasional-Emails: "required"
		},
		messages: 
		{	
			First-Name-3: "Please enter your First Name",
			Last-Name: 
			{
				required: "Please enter your Last Name",
				minlength: "Your password must be at least 2 characters long"
			},				
			Email-Address: 
			{
				required: "Please enter a valid email address",
			},
			Company-Name: 
			{
				required: "Please enter your Company Name",
				minlength: "Your password must be at least 2 characters long"
			},
			Password-2: 
			{
				required: "Please provide a password",
				minlength: "Your password must be at least 8 characters long"
			},
			Verify-Password: 
			{
				required: "Please provide a password",
				minlength: "Your password must be at least 8 characters long",
				equalTo: "Please enter the same password as above"
			},
			Terms-Of-Service: "Please accept our Terms Of Use",
			Privacy-Policy-2: "Please accept our Privacy Policy",
			Occasional-Emails: "Not Required"
		}
	});
});
</script>

Reach out to our resident Javascript Ninja @bartekkustra

1 Like

Could you post a link to your website + public link?

Sure, it’s…

gystusa.webflow.com

Thanks in advance!

If you could please add this link as well ;)

Sorry!

Here it is…

https://webflow.com/design/gystusa?preview=35af4f116861f8f6fc25081cb1b4be7d

Hi Bartekkustra,

Did you get my share link as requested? I posted it here.

Gyst