Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Questions and Supports

Notices

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 02-04-2014, 04:21 PM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 137,014
Kyttias is on a distinguished road
Default

Ok, well, on my test (unrelated to Mysidia):
Code:
<script>
 window.initQueue.push(function(){
	 $("#regusername").focus(function() {
	 $("label[for=regusername]").addClass('error').removeClass('success').removeClass('valid').text('');	 
	 });
	 $("#regusername").focusout(function() {
		 $("label[for=regusername]").addClass('error').removeClass('success').removeClass('valid').text('');	 
	 });
	$("#regusername").focusin(function() {
		$("#message").text("").css({'display' : 'none'});
	});
    $("#regusername").change(function(){
	$("#message").html("Checking...");
	var username=$("#regusername").val();
	 $.ajax({
		type:"post",
		url:"./assets/php/check.php",
		data:"username="+username,
		success:function(data){
			if(data==0){ $("#message").text("Username available!").css({'display' : 'none', 'color' : 'green', 'font-size' : '.8em', 'padding' : '2px 8px', 'margin-top' : '2px'}); }
			else{ $("#message").text("Username already taken!").css({'display' : 'inline-block', 'color' : 'red', 'font-size' : '.8em', 'padding' : '2px 8px', 'margin-top' : '2px'});
				  $("label[for=regusername]").addClass('error').removeClass('success').removeClass('valid').text('');}
			}
		});
	});
});
</script>
I'm using ajax there to push the result from my check.php (which I'd have to reconfigure to work with Mysidia, how do you have yours set up? Save me some some thinking?):
Code:
<?
 
  mysql_connect("127.0.0.1","root","");
  mysql_select_db("test");
 
  $username=$_POST["username"];
  $query=mysql_query("SELECT * from users where Username='$username' ");
 
  $find=mysql_num_rows($query);
 
  echo $find;
 
?>
I'd definitely read up on $.ajax?

You can safely ignore all the adding and removing of success/valid/error classes I did (because I was combining it with another system that also checked for minimum/maximum length requirements... and that passwords had a number, matched, and emails had an @). I was using the same span for both types of confirmation of success and if one was true but not the other, the whole span needed to be red. (ie: Yeah, it fits the minimum requirements for length, but it's taken so it needs to be red and throw and error, not have the green success check.)

Last edited by Kyttias; 02-04-2014 at 04:36 PM.
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
jQuery - Spiffing up your page where you can't edit the HTML! Kyttias Tutorials and Tips 3 01-29-2014 06:09 PM
Jquery one weekend? Tony Other Chat 0 07-30-2011 06:34 PM
Javascript/Jquery not being run. [Answered] exactly33 Questions and Supports 5 12-23-2009 11:39 AM


All times are GMT -5. The time now is 02:17 AM.

Currently Active Users: 3361 (0 members and 3361 guests)
Threads: 4,081, Posts: 32,032, Members: 2,016
Welcome to our newest members, jolob.
BETA





What's New?

What's Hot?

What's Popular?


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
vBCommerce I v2.0.0 Gold ©2010, PixelFX Studios
vBCredits I v2.0.0 Gold ©2010, PixelFX Studios
Emoticons by darkmoon3636