Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-04-2011, 11:43 AM   PM User | #1
jay_jg
New to the CF scene

 
Join Date: May 2011
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
jay_jg is an unknown quantity at this point
.blur problem, I would like to change for a submit button

Hi,

I basically have this script which is working fine, but only works wen I tab off the form, I would like to change it for a submit buttin, I believe I have to change .blur to something else, can anyone help me in the right place? thanks, below are my scripts
Code:
<script src="jquery.js" type="text/javascript" language="javascript"></script>
<script language="javascript">

$(document).ready(function()
{
	
	$("#username").blur(function()
	{
		//remove all the class add the messagebox classes and start fading
		$("#msgbox").removeClass().addClass('messagebox').text('Checking...').fadeIn("slow");
		//check the postcode exists or not from ajax
		$.post("post_code.php",{ user_name:$(this).val() } ,function(data)
        {
		  if(data=='no') //if postcode not avaiable
		  {
		  	$("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
			{ 
			  //add message and change the class of the box and start fading
			  $(this).html('Sorry We Do Not Cover Your Area').addClass('messageboxerror').fadeTo(900,1);
			});		
          }
		  else
		  {
		  	$("#msgbox").fadeTo(200,0.1,function()  //start fading the messagebox
			{ 
			  //add message and change the class of the box and start fading
			  $(this).html('We Cover Your Area').addClass('messageboxok').fadeTo(900,1);	
			});
		  }
				
        });
 
	});
});
</script>
Code:
<input name="username" type="text" id="username" value="" maxlength="15" onChange="javascript:this.value=this.value.toLowerCase();"/>   
   <span id="msgbox" style="display:none"></span>
thanks

Last edited by jay_jg; 05-04-2011 at 11:46 AM..
jay_jg is offline   Reply With Quote
Old 05-04-2011, 10:55 PM   PM User | #2
AndrewGSW
Senior Coder

 
Join Date: Apr 2011
Location: London, England
Posts: 2,120
Thanks: 15
Thanked 354 Times in 353 Posts
AndrewGSW will become famous soon enough
Did you mean specifically a 'submit' button, or just a button? A submit button should really only be used to submit form data.

Code:
<button id="checkName">Check Name</button>
jQuery:
Code:
$(''#checkName').click(function () {
   // check stuff
});
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS
AndrewGSW is offline   Reply With Quote
Users who have thanked AndrewGSW for this post:
jay_jg (05-05-2011)
Old 05-05-2011, 09:13 AM   PM User | #3
jay_jg
New to the CF scene

 
Join Date: May 2011
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
jay_jg is an unknown quantity at this point
Hi Andrew thank you for the reply

Basically when you put in a wrong post code it will say "sorry we do not cover your area", if the user out s a correct post code in it says "we cover your area"

I tried the .click function but even if you put a correct post code in the wrong answer pops up, I could send you the URL if you like?

thanks

Jamie
jay_jg is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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


All times are GMT +1. The time now is 03:46 PM.


Advertisement
Log in to turn off these ads.