Jump to content

Recommended Posts

$(document).ready(function(){

var form = $("#register-form");

	var username = $("#username");
	var username_error = $("#username_error");			
		username.blur(validateName);
		username.keyup(validateName);

	var email = $("#email");
	var email_error = $("#email_error");			
		email.blur(validateEmail);
		email.keyup(validateEmail);

	var password = $("#password");
	var password_error = $("#password_error");			
		password.blur(validatePassword);
		password.keyup(validatePassword);

	var password_confirm = $("#password_confirm");
	var password_confirm_error = $("#password_confirm_error");			
		password_confirm.blur(validatePasswordConfirm);
		password_confirm.keyup(validatePasswordConfirm);

			form.submit(function(){		
					if(validateName() & validateEmail() & validatePassword() & validatePasswordConfirm())					
						return true					
					else				
						return false;					
			});

				function validateName(){				
					if(username.val() == ''){						
						username_error.html('<span class="is_not_available">Please enter a username.</span>');
						return false								 
					}else{
						if(username.val().length < 5){								
							username_error.html('<span class="is_not_available">Username must be a minimum of 5 characters.</span>');							
							return false
						}else{	

							username_error.html('<img src="images/loading.gif" /> Checking...');

							var username1 = $('#username').val();

							$.post("check_username.php", { username: username1 },
								function(result){
									if(result == 1){
										$('#username_error').html('<span class="is_available">' +username1 + ' is available.</span>');
										return true				
									}else{
										$('#username_error').html('<span class="is_not_available">' +username1 + ' is not available.</span>');
										return false
									}
								});						
						}						 			 
					}										
				}

				function validateEmail(){				
					if(email.val() == ''){						
						email_error.html('<span class="is_not_available">Please enter a email.</span>');
						return false								 
					}else{
						email_error.html('<span class="is_not_available"></span>');
						return true						 
					}										
				}

				function validatePassword(){				
					if(password.val() == ''){						
						password_error.html('<span class="is_not_available">Please enter a password.</span>');								 
						return false
					}else{
						password_error.html('<span class="is_not_available"></span>');
						return true							 
					}										
				}

				function validatePasswordConfirm(){				
					if(password_confirm.val() == ''){						
						password_confirm_error.html('<span class="is_not_available">Please enter a password confirmation.</span>');								 
						return false	
					}else{
						password_confirm_error.html('<span class="is_not_available"></span>');
						return true					 
					}										
				}

});

 

the above code does not go to my register-process.php when all ok, but if i take out the below it does...

 

								
							var username1 = $('#username').val();

							$.post("check_username.php", { username: username1 },
								function(result){
									if(result == 1){
										$('#username_error').html('<span class="is_available">' +username1 + ' is available.</span>');
										return true				
									}else{
										$('#username_error').html('<span class="is_not_available">' +username1 + ' is not available.</span>');
										return false
									}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.